Reputation: 9095
TFS build allows to specify conditions for running a task: reference.
The condition I would like to define is: a specific task [addressed by name or other mean] has failed.
This is similar to Only when a previous task has failed
, but I want to specify which previous task that is.
Looking at the examples I don't see any condition that is addressing a specific task outcome, only the entire build status.
Is it possible? any workaround to achieve this?
Upvotes: 1
Views: 2542
Reputation: 32270
It doesn't seem like there's an out-of-the-box solution for this requirement, but I can come up with (an ugly :)) workaround.
Suppose your specific task (the one you examine in regards to its status) is called A
. The goal is to call another build task (let's say B
) only in case A
fails.
You can do the following:
task.A.status
and set to success
C
and schedule it right after A
; condition it to only run if A
fails - there's a standard condition for thatC
should only do one thing - set task.A.status
build variable to 'failure' (like this, if we are talking PowerShell: Write-Host "##vso[task.setvariable variable=task.A.status]failure"
)B
is scheduled sometime after C
and is conditioned to run in case task.A.status
equals failure
, like this: eq(variables['task.A.status'], 'failure')
I might be incorrect in syntax details, but you should get the general idea. Hope it helps.
Upvotes: 2