Dan
Dan

Reputation: 43

Run VSTS Build/Release Task only when previous task errors

I am trying to create a Visual Studio Team Services Extension Task for my builds and releases. I need a task that will send out an alert to another system if a previous task (including the default build/test/publish/etc.) fails.

I have already created the task to send the alert. However I do not see a way to kick off the task only if my build fails.

Is there a way in VSTS to run a task if a previous task fails, but not run it if all other tasks were successful?

Upvotes: 3

Views: 1746

Answers (2)

It is now possible to select a running condition for all tasks with the following possible values:

  • Only when all previous tasks have succeeded
  • Even if a previous task has failed, unless the build was canceled
  • Even if a previous task has failed, even if the build was canceled
  • Only when a previous task has failed
  • Custom conditions

"Only when a previous task has failed" condition selected

EDIT:
It is currently part of a preview, you can enable it through the "Preview features" menu after you click on your profile click on VSTS:
Profile menu

And activate the "New Build Editor":
Preview features menu

Upvotes: 3

jessehouwing
jessehouwing

Reputation: 114857

There is no built-in feature.

But you can use the "Rollback" task from the Release Management Utilities to run a powershell script on failure.

Upvotes: 2

Related Questions