Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a job fail in jenkins

Tags:

python

jenkins

This question might sound weird, but how do I make a job fail?

I have a python script that compiles few files using scons, and which is running as a jenkins job. The script tests if the compiler can build x64 or x86 binaries, I want the job to fail if it fails to do one of these.

For instance: if I'm running my script on a 64-bit system and it fails to compile a 64-bit. Is there something I can do in the script that might cause to fail?

like image 638
cyberbemon Avatar asked Aug 20 '12 11:08

cyberbemon


People also ask

How do you fail a Jenkins build?

You can use the error step from the pipeline DSL to fail the current build. error("Build failed because of this and that..")

How do you stop a running job in Jenkins?

Pipeline jobs can be stopped by sending an HTTP POST request to URL endpoints of a build. BUILD ID URL/stop - aborts a Pipeline. BUILD ID URL/term - forcibly terminates a build (should only be used if stop does not work). BUILD ID URL/kill - hard kill a pipeline.

What happens if build fails in Jenkins?

In Jenkins, in the pipeline where failure occurred, in the pane, select the latest build, and click Console Output. On the Console Output page, check the logs to find the reason for the failure. If required, update the parameters in the deployment input configuration file.


1 Answers

If your script exit with a non-zero status the build should fail.

import sys
sys.exit(-1)
like image 183
Y__ Avatar answered Oct 04 '22 11:10

Y__