huserben / TfsExtensions

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

triggered build pipeline finishes in warning, but parent pipeline was not successfull #251

Closed vicente-espinha closed 8 months ago

vicente-espinha commented 8 months ago

I created a build pipeline "B", which uses the task "Trigger Build" (version 3) to trigger multiple pipelines. Sometimes one of the triggered pipelines finished in "Warning" and the pipeline "B" finished in "Failed" with an error like "pipeline x was not successful".

Why is this the case? Shouldn't it continue the pipeline "B"'s execution when the triggered pipelines are not failing (only in "Warning")?

Please let me know if you need more details about this issue.

huserben commented 8 months ago

Hi @vicente-espinha

if a pipeline has warnings, it's "partially successful". As stated in the docs, you can treat them as "successful". The default is that partially successful is causing an error, but you can override this behavior.

Please let me know if that solved your problem.

vicente-espinha commented 8 months ago

Hi @huserben It "partially" solved the issue :smile: . It was happening a strange behaviour. The build pipeline is represented in the image below. The task "A" triggers multiple pipelines, including the one which finished in "warning". image This task had the following advanced configurations: image So, as you said, task "A" is successful, but (I do not know why) task "B" fails because it does not have the "Treat a Partially Succeeded Build as Successful" checked. It fails on a build definition which was triggered by task "A". Why does this happen?

Note: I tested adding the "Treat a Partially Succeeded Build as Successful" configuration to tasks "B" and "C" and solved the issue, but I do not understand why 🤷‍♂️

huserben commented 8 months ago

Ok, this is indeed interesting.

I think what's happening is this:

So to solve this, you can treat them as successfull as you did, but this might have unintended side effects (if you don't want to accept partially successful pipelines triggered by Task B). The other, and I think cleaner, option would be: Simply "uncheck" the "Store triggered build id's in a variable" for Task A (and potentially also the other tasks).

More info on this in the docs:

If any subsequent task needs the info of which builds were triggered by this Task, this information is available as an environment variable to the subsequent Tasks. The name of the variable is TriggeredBuildIds. If more than one build will be triggered, the values will be written comma separated. If there is already a value in the variable from a previous Task, it not overwritten but keep the original value and append his resulting build id's.

Can you try this out and see if it solves your problem?

Thanks for raising this!

vicente-espinha commented 8 months ago

Yes, it works! Now, tasks "B" and "C" do not fail.

Thank you for your time and support!