Job execution in jenkins

This question may seem strange, but how can I make the job unsuccessful?

I have a python script that compiles multiple files using scons and works like jenkins work. The script checks if the compiler can create x64 or x86 binaries, I want the task to fail if it could not perform one of these actions.

For example: if I run my script on a 64-bit system and it cannot compile the 64-bit version. Is there something I can do in a script that could crash?

+5
source share
3 answers

If your script exits with a non-zero status, the assembly should fail.

import sys
sys.exit(-1)
+5
source

, python script - jenkins, . - , " " .

jenkins

echo "exit(1)" >> test.py
python test.py

, jenkins

echo "exit(1)" >> test.py
python test.py
echo "This changes my exit code back to 0, which is successful"
+4

You can throw an exception at any time. If it is not processed, the application will stop. You do not even need to indicate which exception you are raising.

if not yourTestHere:
    raise

If you want to specify a message, you can simply raise a standard exception.

from exceptions import Exception
if not yourTestHere:
    raise Exception("Script failed because of bla bla bla")
+1
source

All Articles