Rubén M
Rubén M

Reputation: 119

Azure Devops exclude job if branch tag is present

My Azure DevOps pipeline has 3 jobs. One builds the project for production and the other builds it for testing and the last publish artifacts. When I push to release branch, it triggers all of 3 jobs, but they can take 10-15 minutes to finish. What I'm trying to achieve is exclude testing job if a tag is present on the commit or something like that.

Ex. Don't trigger test job if branch tag has "hotfix". Tryed "Run this job with conditions" in job's settings with this value "not(startsWith(variables['Build.SourceBranch'], 'refs/tags/hotfix'))" but if I push something to release with hotfix tag it still runs.

Thanks

Upvotes: 0

Views: 1344

Answers (1)

Felix
Felix

Reputation: 1162

We recommend you can use the conditions:

condition: eq(variables['Build.SourceBranch'], 'refs/tags/test')

And this means if you want the test job to run, then you need to push something to release with test tag. We cannot use the value "not(startsWith(variables['Build.SourceBranch'], 'refs/tags/hotfix'))" On my test, if I push the commit release with hotfix tag, then the test job will be skipped. enter image description here

Update:

We can use the Custom conditions in Additional options, and set it as :

eq(variables['Build.SourceBranch'], 'refs/tags/test')

enter image description here

More details, you can refer this doc: Expressions

Upvotes: 0

Related Questions