Reputation: 3
I have a single YAML config file for an Azure DevOps pipeline which has the following trigger:
trigger:
branches:
include:
- develop
- release/*
And I would like to be able to conditionally run it on develop, according to what pipeline parameters are selected when the pipeline is run, something like:
trigger:
branches:
(if parameter.Foo = true trigger develop)
include:
- develop
(if parameter.Bar = true trigger release/*)
- release/*
I looked at official Microsoft Azure DevOps documentation but could find anything similar, only that maybe something related to what I want could be achieved with Branch Policies in Azure DevOps.
Upvotes: 0
Views: 1394
Reputation: 16133
The triggers do not support IF statements. However, you may try to use conditions on the job level:
Example:
trigger:
branches:
include:
- develop
- release/*
jobs:
- job: MyJob
displayName: My First Job
condition: and(succeeded(), or( and( eq(variables['Build.SourceBranch'], 'refs/heads/develop'), eq('${{ parameters.Foo }}', true)), and( startsWith(variables['Build.SourceBranch'], 'refs/heads/release'), eq('${{ parameters.Bar }}', true))))
workspace:
clean: outputs
steps:
- script: echo My first job
Upvotes: 0