Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
3f2ab68b
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
3f2ab68b
编写于
1月 13, 2011
作者:
O
Olivier Lamy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[HUDSON-8415] M2 and M3 builds behave differently when tests fail
上级
32a344ff
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
86 addition
and
9 deletion
+86
-9
maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java
...rc/main/java/hudson/maven/reporters/SurefireArchiver.java
+34
-9
test/src/test/java/hudson/maven/MavenBuildSurefireFailedTest.java
.../test/java/hudson/maven/MavenBuildSurefireFailedTest.java
+52
-0
test/src/test/resources/hudson/maven/maven-multimodule-unit-failure.zip
...resources/hudson/maven/maven-multimodule-unit-failure.zip
+0
-0
未找到文件。
maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java
浏览文件 @
3f2ab68b
...
...
@@ -23,8 +23,8 @@
*/
package
hudson.maven.reporters
;
import
hudson.Util
;
import
hudson.Extension
;
import
hudson.Util
;
import
hudson.maven.Maven3Builder
;
import
hudson.maven.MavenBuild
;
import
hudson.maven.MavenBuildProxy
;
...
...
@@ -40,12 +40,6 @@ import hudson.model.BuildListener;
import
hudson.model.Result
;
import
hudson.tasks.junit.TestResult
;
import
hudson.tasks.test.TestResultProjectAction
;
import
org.apache.maven.plugin.MojoFailureException
;
import
org.apache.maven.project.MavenProject
;
import
org.apache.tools.ant.DirectoryScanner
;
import
org.apache.tools.ant.types.FileSet
;
import
org.codehaus.plexus.component.configurator.ComponentConfigurationException
;
import
org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -54,6 +48,16 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.ListIterator
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.maven.artifact.versioning.ComparableVersion
;
import
org.apache.maven.plugin.MojoFailureException
;
import
org.apache.maven.project.MavenProject
;
import
org.apache.tools.ant.DirectoryScanner
;
import
org.apache.tools.ant.types.FileSet
;
import
org.codehaus.plexus.component.configurator.ComponentConfigurationException
;
import
org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration
;
import
org.codehaus.plexus.util.xml.Xpp3Dom
;
/**
* Records the surefire test result.
* @author Kohsuke Kawaguchi
...
...
@@ -68,8 +72,21 @@ public class SurefireArchiver extends MavenReporter {
// so that we can record this as yellow.
// note that because of the way Maven works, just updating system property at this point is too late
XmlPlexusConfiguration
c
=
(
XmlPlexusConfiguration
)
mojo
.
configuration
.
getChild
(
"testFailureIgnore"
);
if
(
c
!=
null
&&
c
.
getValue
().
equals
(
"${maven.test.failure.ignore}"
)
&&
System
.
getProperty
(
"maven.test.failure.ignore"
)==
null
)
c
.
setValue
(
"true"
);
if
(
c
!=
null
&&
c
.
getValue
().
equals
(
"${maven.test.failure.ignore}"
)
&&
System
.
getProperty
(
"maven.test.failure.ignore"
)==
null
)
{
if
(
maven3orLater
(
build
.
getMavenBuildInformation
().
getMavenVersion
()
))
{
String
fieldName
=
"testFailureIgnore"
;
if
(
mojo
.
mojoExecution
.
getConfiguration
().
getChild
(
fieldName
)
!=
null
)
{
mojo
.
mojoExecution
.
getConfiguration
().
getChild
(
fieldName
).
setValue
(
Boolean
.
TRUE
.
toString
()
);
}
else
{
Xpp3Dom
child
=
new
Xpp3Dom
(
fieldName
);
child
.
setValue
(
Boolean
.
TRUE
.
toString
()
);
mojo
.
mojoExecution
.
getConfiguration
().
addChild
(
child
);
}
}
else
{
c
.
setValue
(
Boolean
.
TRUE
.
toString
());
}
}
}
}
return
true
;
...
...
@@ -213,6 +230,14 @@ public class SurefireArchiver extends MavenReporter {
return
true
;
}
public
boolean
maven3orLater
(
String
mavenVersion
)
{
// null or empty so false !
if
(
StringUtils
.
isBlank
(
mavenVersion
))
{
return
false
;
}
return
new
ComparableVersion
(
mavenVersion
).
compareTo
(
new
ComparableVersion
(
"3.0"
)
)
>=
0
;
}
@Extension
public
static
final
class
DescriptorImpl
extends
MavenReporterDescriptor
{
public
String
getDisplayName
()
{
...
...
test/src/test/java/hudson/maven/MavenBuildSurefireFailedTest.java
0 → 100755
浏览文件 @
3f2ab68b
package
hudson.maven
;
import
hudson.model.Result
;
import
hudson.tasks.Maven.MavenInstallation
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.ExtractResourceSCM
;
import
org.jvnet.hudson.test.HudsonTestCase
;
/**
* @author Olivier Lamy
*/
public
class
MavenBuildSurefireFailedTest
extends
HudsonTestCase
{
@Bug
(
8415
)
public
void
testMaven2Unstable
()
throws
Exception
{
configureDefaultMaven
();
MavenModuleSet
m
=
createMavenProject
();
m
.
setGoals
(
"test"
);
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"maven-multimodule-unit-failure.zip"
)));
assertBuildStatus
(
Result
.
UNSTABLE
,
m
.
scheduleBuild2
(
0
).
get
());
}
@Bug
(
8415
)
public
void
testMaven2Failed
()
throws
Exception
{
configureDefaultMaven
();
MavenModuleSet
m
=
createMavenProject
();
m
.
setGoals
(
"test -Dmaven.test.failure.ignore=false"
);
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"maven-multimodule-unit-failure.zip"
)));
assertBuildStatus
(
Result
.
FAILURE
,
m
.
scheduleBuild2
(
0
).
get
());
}
@Bug
(
8415
)
public
void
testMaven3Unstable
()
throws
Exception
{
MavenModuleSet
m
=
createMavenProject
();
m
.
setMaven
(
configureMaven3
().
getName
()
);
m
.
setGoals
(
"test"
);
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"maven-multimodule-unit-failure.zip"
)));
assertBuildStatus
(
Result
.
UNSTABLE
,
m
.
scheduleBuild2
(
0
).
get
());
}
@Bug
(
8415
)
public
void
testMaven3Failed
()
throws
Exception
{
MavenModuleSet
m
=
createMavenProject
();
m
.
setMaven
(
configureMaven3
().
getName
()
);
m
.
setGoals
(
"test -Dmaven.test.failure.ignore=false"
);
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"maven-multimodule-unit-failure.zip"
)));
assertBuildStatus
(
Result
.
FAILURE
,
m
.
scheduleBuild2
(
0
).
get
());
}
}
test/src/test/resources/hudson/maven/maven-multimodule-unit-failure.zip
0 → 100755
浏览文件 @
3f2ab68b
此差异由.gitattributes 抑制。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录