huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
44 stars 22 forks source link

Cancel child build if the parent build fails #72

Closed atlesp closed 6 years ago

atlesp commented 6 years ago

I now end up with "orphaned" build if the parent build fails, and those are blocking other builds from starting (have not that many build agents).

So a task to cancel a child build, that can be configured to run if some of the previous steps fail, would have been nice to have.

huserben commented 6 years ago

Hi @atlesp

Just so that I get the problem correct: Your use case is that you Trigger a Build and don't await the result of it, but in parallel you continue with your "main" build. And if this one fails, you would like to cancel the running one?

atlesp commented 6 years ago

hi @huserben Yes, that is correct. My builds run for a while and are only split to speed up the build, and the result are merged together at the end of the master build.

huserben commented 6 years ago

Ok, thanks for the clarification.

I will look into a seperate task that will be cancelling builds that were triggered. However I'm not sure how long it will take as I don't have too much free time on my hands, so I can not make any promises.

As soon as anything updates I will let you know in here.

huserben commented 6 years ago

Hi @atlesp

I just uploaded a new version of the package that includes a CancelBuild Task. grafik

The configuration is pretty much the same as for the regular triggering of builds, you only need the specifiy the authentication options. It will read the id's of the builds that were triggered in previous steps, so please make sure to set the flag to store the build id under advanced configuration for all the builds you want to be cancelled: grafik

Then in order to achieve your goal, I think you can add this task at the very end and setup the "Control Options" to only run the task when a previous task has failed: grafik

Can you please try it out and let me know whether it worked or not?

atlesp commented 6 years ago

Thanks @huserben ! I have added it to our build now and will test it.

atlesp commented 6 years ago

A dev accidentally tested it for me now and it worked fine! Thanks again.

huserben commented 6 years ago

@atlesp

Very good. Thanks for your improvement proposal. Please don't hesitate to open an issue if you have another one, or you find a bug or have a question in general.