Home > front end >  Azure devops Condition
Azure devops Condition

Time:02-03

Trying to find the right condition to run job only after PR doing merge to master only.

I tried it but still after merge the job did not run:

condition: and(succeeded(), variables['System.PullRequest'], 'PullRequest')

CodePudding user response:

There isn't really one. After the merge completes, it's just seen as any other push to master.

You can probably use the REST API against Azure Repos to find whether that commit is associated to a pull request, but you only get the pull request context for the validation builds, not for the build that triggers on the completed merge result.

CodePudding user response:

You can have a variable named i.e. isPullRequest:

variables:
  isPullRequest: ${{eq(variables['Build.Reason'], 'PullRequest')}}

Then in the condition of the job that you want to skip in Pull Requests:

condition: and(succeeded(), eq(variables.isPullRequest, 'false'))
  •  Tags:  
  • Related