Is there information available when executing jenkins postbuild script about job status

此生再无相见时 提交于 2019-12-13 03:33:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!