TeamCity job, run step only if a previous one has failed?

风格不统一 提交于 2019-12-21 03:41:05

问题


We're using TeamCity 7 and wondered if it's possible to have a step run only if a previous one has failed? Our options in the build step configuration give you the choice to execute only if all steps were successful, even if a step failed, or always run it.

Is there a means to execute a step only if a previous one failed?


回答1:


Theres no way to setup a step to execute only if a previous one failed.

The closest I've seen to this, is to setup a build that has a "Finish Build" trigger that would always execute after your first build finishes. (Regardless of success or failure).

Then in that second build, you could use the TeamCity REST API to determine if the last execution from the first build was successful or not. If it wasn't successful then you could whatever it is you want to do.




回答2:


As a work around it is possible to set a variable via a command line step that only runs on success which can be checked later.

echo "##teamcity[setParameter name='env.BUILD_STATUS' value='SUCCESS']"

This can then be queried inside a powershell step that is set to run even if a step fails.

if($env:BUILD_STATUS -ne "SUCCESS"){

}



回答3:


Another solution is Webhooks.

This plugin can send webhook to an URL if build fails too. On the webhook side, you can handle some actions, for example, send notification.



来源:https://stackoverflow.com/questions/19689093/teamcity-job-run-step-only-if-a-previous-one-has-failed

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