Modifying Buildbot exit code using compiled java code
-
14-07-2021 - |
Question
I recently began work on continuous integration systems and started to learn how to use Buildbot.
I have a buildslave that runs on every commit, and I wanted to add a new step to parse certain data files after the build has completed and based on the results trigger a build pass/fail.
buildSteps.addStep(shell.ShellCommand( description=["File Parser"], workdir=dataDirectory, command=["call", "ant", "ParseTest"] ) )
At the end of the step, the output resembles this:
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 38 seconds
program finished with exit code 0
In the java code I am using System.exit(1) to represent a failure and System.exit(0) to represent success.
So my question is, How can I change the actual exit code to a non-zero value so Buildbot recognizes it as a failed build?
Solution
I don't know buildbot but the failonerror attribute from ant java task is default set to false.
So to get a BUILD FAILED if java exits with a returncode other than 0 you have to set the
failonerror attribute from java task to true.