What is the preferred way to disable the periodical build when it has failed? Quick search showed that there is a Prerequisite build step plugin, but that fails the build, and I need the build to be completely disabled until manual intervention.
Thanks.
Okay, I think I managed to find a solution.
The solution is to install the Groovy Postbuild Plugin, which is run under the Jenkins JVM and exposes the Jenkins instance publically. So it is possible to programmatically disable the current build directly in the Project configuration:
if (manager.build.result.isWorseThan(hudson.model.Result.SUCCESS)) {
manager.build.project.disabled = true
}
There is a button "Disable project" on the project status page. I simulate button click by HTTP POST message with data "Submit=\"Disable Project\"" like this
wget --post-data "Submit=\"Disable Project\"" ${JOB_URL}disable
right from the bash script which runs the build (project). The whole code can look like this
set +e
# Run test/build
# ....
if [ $? -ne 0 ];
then
wget --post-data "Submit=\"Disable Project\"" ${JOB_URL}disable
# Or you can use following to disable one job from another
# wget --post-data "Submit=\"Disable Project\"" http://<Server>/job/$JOB_NAME/disable
exit -1
fi
This is a rather old question, so I guess there was no Disable/Enable button in Jenkins GUI than. If Jenkins is protected by a password you will need to make wget to login first, store cookies in some file and in the second file add the cookie.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With