Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
a92e9da9
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a92e9da9
编写于
8月 20, 2013
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-18846] Update symlinks for Maven module builds.
上级
a89edffa
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
86 addition
and
25 deletion
+86
-25
changelog.html
changelog.html
+3
-1
core/src/main/java/hudson/model/AbstractBuild.java
core/src/main/java/hudson/model/AbstractBuild.java
+0
-22
core/src/main/java/hudson/model/Run.java
core/src/main/java/hudson/model/Run.java
+36
-2
maven-plugin/src/main/java/hudson/maven/MavenBuild.java
maven-plugin/src/main/java/hudson/maven/MavenBuild.java
+9
-0
test/src/test/java/hudson/maven/MavenMultiModuleTest.java
test/src/test/java/hudson/maven/MavenMultiModuleTest.java
+38
-0
未找到文件。
changelog.html
浏览文件 @
a92e9da9
...
...
@@ -55,7 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div
id=
"trunk"
style=
"display:none"
>
<!--=TRUNK-BEGIN=-->
<ul
class=
image
>
<li
class=
>
<li
class=
bug
>
Build number symlinks and permalinks not updated for Maven module builds.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-18846"
>
issue 18846
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/model/AbstractBuild.java
浏览文件 @
a92e9da9
...
...
@@ -37,7 +37,6 @@ import hudson.console.ModelHyperlinkNote;
import
hudson.matrix.MatrixConfiguration
;
import
hudson.model.Fingerprint.BuildPtr
;
import
hudson.model.Fingerprint.RangeSet
;
import
hudson.model.PermalinkProjectAction.Permalink
;
import
hudson.model.listeners.RunListener
;
import
hudson.model.listeners.SCMListener
;
import
hudson.scm.ChangeLogParser
;
...
...
@@ -59,7 +58,6 @@ import hudson.tasks.test.AbstractTestResultAction;
import
hudson.tasks.test.AggregatedTestResultAction
;
import
hudson.util.*
;
import
jenkins.model.Jenkins
;
import
jenkins.model.PeepholePermalink
;
import
jenkins.model.lazy.AbstractLazyLoadRunMap.Direction
;
import
jenkins.model.lazy.BuildReference
;
import
org.kohsuke.stapler.HttpResponse
;
...
...
@@ -477,23 +475,6 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return
hudsonVersion
;
}
/**
* Backward compatibility.
*
* We used to have $JENKINS_HOME/jobs/JOBNAME/lastStable and lastSuccessful symlinked to the appropriate
* builds, but now those are done in {@link PeepholePermalink}. So here, we simply create symlinks that
* resolves to the symlink created by {@link PeepholePermalink}.
*/
private
void
createSymlink
(
TaskListener
listener
,
String
name
,
Permalink
target
)
throws
InterruptedException
{
String
targetDir
;
if
(
getProject
().
getBuildDir
().
equals
(
new
File
(
getProject
().
getRootDir
(),
"builds"
)))
{
targetDir
=
"builds"
+
File
.
separator
+
target
.
getId
();
}
else
{
targetDir
=
getProject
().
getBuildDir
()
+
File
.
separator
+
target
.
getId
();
}
Util
.
createSymlink
(
getProject
().
getRootDir
(),
targetDir
,
name
,
listener
);
}
/**
* @deprecated as of 1.467
* Please use {@link hudson.model.Run.RunExecution}
...
...
@@ -724,9 +705,6 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
public
final
void
post
(
BuildListener
listener
)
throws
Exception
{
try
{
post2
(
listener
);
createSymlink
(
listener
,
"lastSuccessful"
,
Permalink
.
LAST_SUCCESSFUL_BUILD
);
createSymlink
(
listener
,
"lastStable"
,
Permalink
.
LAST_STABLE_BUILD
);
}
finally
{
// update the culprit list
HashSet
<
String
>
r
=
new
HashSet
<
String
>();
...
...
core/src/main/java/hudson/model/Run.java
浏览文件 @
a92e9da9
...
...
@@ -121,6 +121,7 @@ import java.io.StringWriter;
import
static
java
.
util
.
logging
.
Level
.*;
import
javax.annotation.CheckForNull
;
import
javax.annotation.Nonnull
;
import
jenkins.model.PeepholePermalink
;
import
jenkins.model.RunAction2
;
/**
...
...
@@ -1597,8 +1598,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
RunListener
.
fireStarted
(
this
,
listener
);
// create a symlink from build number to ID.
Util
.
createSymlink
(
getParent
().
getBuildDir
(),
getId
(),
String
.
valueOf
(
getNumber
()),
listener
);
updateSymlinks
(
listener
);
setResult
(
job
.
run
(
listener
));
...
...
@@ -1674,6 +1674,40 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
}
}
/**
* Creates a symlink from build number to ID.
* Also makes sure that {@code lastSuccessful} and {@code lastStable} legacy links in the project’s root directory exist.
* Normally you do not need to call this explicitly, since {@link #execute} does so,
* but this may be needed if you are creating synthetic {@link Run}s as part of a container project (such as Maven builds in a module set).
* You should also ensure that {@link RunListener#fireStarted} and {@link RunListener#fireCompleted} are called.
* @param listener probably unused
* @throws InterruptedException probably not thrown
* @since 1.530
*/
public
final
void
updateSymlinks
(
TaskListener
listener
)
throws
InterruptedException
{
Util
.
createSymlink
(
getParent
().
getBuildDir
(),
getId
(),
String
.
valueOf
(
getNumber
()),
listener
);
createSymlink
(
listener
,
"lastSuccessful"
,
PermalinkProjectAction
.
Permalink
.
LAST_SUCCESSFUL_BUILD
);
createSymlink
(
listener
,
"lastStable"
,
PermalinkProjectAction
.
Permalink
.
LAST_STABLE_BUILD
);
}
/**
* Backward compatibility.
*
* We used to have $JENKINS_HOME/jobs/JOBNAME/lastStable and lastSuccessful symlinked to the appropriate
* builds, but now those are done in {@link PeepholePermalink}. So here, we simply create symlinks that
* resolves to the symlink created by {@link PeepholePermalink}.
*/
private
void
createSymlink
(
TaskListener
listener
,
String
name
,
PermalinkProjectAction
.
Permalink
target
)
throws
InterruptedException
{
File
buildDir
=
getParent
().
getBuildDir
();
File
rootDir
=
getParent
().
getRootDir
();
String
targetDir
;
if
(
buildDir
.
equals
(
new
File
(
rootDir
,
"builds"
)))
{
targetDir
=
"builds"
+
File
.
separator
+
target
.
getId
();
}
else
{
targetDir
=
buildDir
+
File
.
separator
+
target
.
getId
();
}
Util
.
createSymlink
(
rootDir
,
targetDir
,
name
,
listener
);
}
/**
* Handles a fatal build problem (exception) that occurred during the build.
*/
...
...
maven-plugin/src/main/java/hudson/maven/MavenBuild.java
浏览文件 @
a92e9da9
...
...
@@ -41,6 +41,7 @@ import hudson.model.Node;
import
hudson.model.Result
;
import
hudson.model.Run
;
import
hudson.model.TaskListener
;
import
hudson.model.listeners.RunListener
;
import
hudson.remoting.Channel
;
import
hudson.scm.ChangeLogSet
;
import
hudson.scm.ChangeLogSet.Entry
;
...
...
@@ -73,6 +74,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.annotation.CheckForNull
;
...
...
@@ -497,6 +499,7 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
RunListener
.
fireStarted
(
MavenBuild
.
this
,
listener
);
}
public
void
end
()
{
...
...
@@ -512,6 +515,12 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
updateSymlinks
(
listener
);
}
catch
(
InterruptedException
x
)
{
Logger
.
getLogger
(
MavenBuild
.
class
.
getName
()).
log
(
Level
.
WARNING
,
null
,
x
);
}
RunListener
.
fireCompleted
(
MavenBuild
.
this
,
listener
);
}
/**
...
...
test/src/test/java/hudson/maven/MavenMultiModuleTest.java
浏览文件 @
a92e9da9
package
hudson.maven
;
import
com.gargoylesoftware.htmlunit.html.HtmlPage
;
import
hudson.Functions
;
import
org.junit.Assert
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.ExtractResourceSCM
;
...
...
@@ -8,16 +9,23 @@ import org.jvnet.hudson.test.ExtractResourceWithChangesSCM;
import
org.jvnet.hudson.test.ExtractChangeLogSet
;
import
hudson.Launcher
;
import
hudson.Util
;
import
hudson.maven.reporters.MavenArtifactRecord
;
import
hudson.maven.reporters.MavenFingerprinter
;
import
hudson.model.AbstractBuild
;
import
hudson.model.BuildListener
;
import
hudson.model.Job
;
import
hudson.model.PermalinkProjectAction
;
import
hudson.model.Result
;
import
hudson.tasks.Fingerprinter.FingerprintAction
;
import
hudson.tasks.Maven.MavenInstallation
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Assume
;
import
org.junit.Ignore
;
import
org.junit.Rule
;
import
org.junit.Test
;
...
...
@@ -43,6 +51,36 @@ public class MavenMultiModuleTest {
j
.
buildAndAssertSuccess
(
m
);
}
@Bug
(
18846
)
@Test
public
void
symlinksUpdated
()
throws
Exception
{
Assume
.
assumeFalse
(
Functions
.
isWindows
());
j
.
configureDefaultMaven
();
MavenModuleSet
mms
=
j
.
createMavenProject
();
mms
.
setScm
(
new
ExtractResourceSCM
(
MavenMultiModuleTest
.
class
.
getResource
(
"maven-multimod.zip"
)));
j
.
buildAndAssertSuccess
(
mms
);
MavenModule
mm
=
mms
.
getModule
(
"org.jvnet.hudson.main.test.multimod:moduleA"
);
j
.
buildAndAssertSuccess
(
mms
);
assertEquals
(
2
,
mms
.
getLastStableBuild
().
number
);
assertEquals
(
mms
.
getLastBuild
().
getId
(),
Util
.
resolveSymlink
(
new
File
(
mms
.
getRootDir
(),
"builds/2"
)));
assertEquals
(
"2"
,
Util
.
resolveSymlink
(
new
File
(
mms
.
getRootDir
(),
"builds/lastStableBuild"
)));
assertEquals
(
"builds/lastStableBuild"
,
Util
.
resolveSymlink
(
new
File
(
mms
.
getRootDir
(),
"lastStable"
)));
assertEquals
(
"[lastBuild, lastStableBuild, lastSuccessfulBuild]"
,
permalinks
(
mms
).
toString
());
assertEquals
(
2
,
mm
.
getLastStableBuild
().
number
);
assertEquals
(
mm
.
getLastBuild
().
getId
(),
Util
.
resolveSymlink
(
new
File
(
mm
.
getRootDir
(),
"builds/2"
)));
assertEquals
(
"2"
,
Util
.
resolveSymlink
(
new
File
(
mm
.
getRootDir
(),
"builds/lastStableBuild"
)));
assertEquals
(
"builds/lastStableBuild"
,
Util
.
resolveSymlink
(
new
File
(
mm
.
getRootDir
(),
"lastStable"
)));
assertEquals
(
"[lastBuild, lastStableBuild, lastSuccessfulBuild]"
,
permalinks
(
mm
).
toString
());
}
private
static
Set
<
String
>
permalinks
(
Job
<?,?>
j
)
{
Set
<
String
>
r
=
new
TreeSet
<
String
>();
for
(
PermalinkProjectAction
.
Permalink
l
:
j
.
getPermalinks
())
{
if
(
l
.
resolve
(
j
)
!=
null
)
{
r
.
add
(
l
.
getId
());
}
}
return
r
;
}
@Test
public
void
incrementalMultiModMaven
()
throws
Exception
{
j
.
configureDefaultMaven
(
"apache-maven-2.2.1"
,
MavenInstallation
.
MAVEN_21
);
MavenModuleSet
m
=
j
.
createMavenProject
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录