简体   繁体   中英

Jenkins build not failing when maven deploy task fails

I have a Jenkins (Maven) job that builds and deploys a web service to a Tomcat 8 server.

If the deployment to the Tomcat fails the Jenkins job still finishes with success.

[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

Is there a way to make the Jenkins job fail if the deployment fails?

若你使用jenkins我建议你使用jenkins deploy plugin https://wiki.jenkins-ci.org/display/JENKINS/Deploy+Plugin

I think this is a bug in the tomcat maven plugin.

I had the same problem and use Jenkins plugin called Jenkins Text Finder. I added a post-build action called "Jenkins Text Finder" to the end of my Jenkins job. I leave the "Files" input box empty, but check the "Also search the console output" checkbox. In the regular expression inputbox I put "but context failed to start". The other two checkboxes remain unchecked.

This leads to the following output

[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

which is good enough for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM