当maven部署任务失败时,Jenkins构建不会失败

时间:2016-10-25 12:31:01

标签: maven jenkins deployment tomcat8

我有一个Jenkins(Maven)工作,可以为Tomcat 8服务器构建和部署Web服务。

如果部署到Tomcat失败,Jenkins作业仍然会成功完成。

[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] FAIL - Deployed application at context path /dims but context failed to start
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.625s
[INFO] Finished at: Tue Oct 25 12:14:21 CEST 2016
[INFO] Final Memory: 17M/40M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS

如果部署失败,有没有办法让Jenkins作业失败?

2 个答案:

答案 0 :(得分:0)

如果您使用jenkins,我建议您使用jenkins deploy plugin https://wiki.jenkins-ci.org/display/JENKINS/Deploy+Plugin

答案 1 :(得分:0)

我认为这是tomcat maven插件中的一个错误。

我有同样的问题,并使用名为Jenkins Text Finder的Jenkins插件。我添加了一个名为" Jenkins Text Finder"到詹金斯的工作结束。我离开"文件"输入框为空,但检查"还要搜索控制台输出"复选框。在正则表达式输入框中我放了"但是上下文无法启动"。其他两个复选框仍未选中。

这导致以下输出

[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] FAIL - Deployed application at context path / but context failed to start
[INFO] ----------------
[INFO] BUILD SUCCESS
[INFO] ----------------
[INFO] Total time: 01:23 min
[INFO] Finished at: 2016-12-29T21:15:41+01:00
[INFO] Final Memory: 117M/472M
[JENKINS] Archiving /var/lib/jenkins/workspace/jenkins-test/core/pom.xml to cz.semanta/xf3/r8_2/xf3-r8_2.pom
[INFO] ---------------------
channel stopped
Checking console output
/var/lib/jenkins/jobs/jenkins-test/builds/6/log:
[INFO] FAIL - Deployed application at context path / but context failed to start
Build step 'Jenkins Text Finder' changed build result to FAILURE
An attempt to send an e-mail to empty list of recipients, ignored.
Finished: FAILURE

这对我来说已经足够了。