Engern
Engern

Reputation: 887

Azure Devops build custom conditions -target previous build

Is it possible to target the previous build in a custom condition?

What I try to accomplish:

  1. Post a message to Slack when build fails (this is easy)
  2. Post a message to Slack when a build changes status from failed to success (I don't want all successful builds posted to Slack, only the first one after a failed build)

Upvotes: 0

Views: 128

Answers (2)

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31075

No, it's not able to target the previous build in a custom condition. Custom condition can only target in the same build. You can add a task to use REST API checking the previous build result and current build result, and determine whether to post a message to Slack.

Upvotes: 1

Zach Stephens
Zach Stephens

Reputation: 1

One way would be to retrieve the latest build and read the build status using the Rest API. The Slack message would then be conditional on previous BuildResult == succeeded & current BuildResult == failed.

You can get information about the previous build using the azure-devops rest API here:

Azure DevOps Services Rest API GET Builds List

Upvotes: 0

Related Questions