Conditions in azure pipelines you didn't know you needed.

·

1 min read

#To run only for Pull requests ( to do the inverse use 'ne' instead of 'eq')
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))

#To run when the Pull request is merged.
 condition: and(succeeded(), startsWith(variables['Build.SourceVersionMessage'], 'Merged PR '))

#To run a stage only when the sourece branch is 'master'
- stage: DeployQA
  displayName: 'Deploy QA Stage'
  condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
  dependsOn: DeployDev