问题
I need to run certain shell command if build fails. Is there any variable passed to shell that contains such info? Or maybe I can find it in file?
I need something like that:
if [ $build_status == "FAIL" ]
then
do_the_magic
fi
I have already printed env
and there is nothing that would directly say that build failed.
回答1:
You are looking for the Conditional Build Step Plugin. Add a "Conditional step (single)" as your last build step and use "Current Build Status" for your condition. I like this plugin, but havent't used this particular condition yet.
回答2:
Same solution explained step by step..Really easy, maybe not to elegant, but it works!
1: Catch all the build result you want to catch (in this case SUCCESS).
2: Inject an env variable valued with the job status
3: Do the Same for any kind of other status (in this case I catch from abort to unstable)
4: After you'll be able to use the value for whatever you wanna do.. in this case I'm passing it to an ANT script! (Or you can directly load it from ANT as Environment variable...)
Hope it can help!
来源:https://stackoverflow.com/questions/19381124/is-there-information-available-when-executing-jenkins-postbuild-script-about-job