1

I have 2 pipelines currently one is linked to my dev branch and one is linked to my master branch. But both the YAML files have the same name but have different scripts within it so the problem is when I merge my dev into my production branch it changes the yaml file inside the master brance. Is there a workaround this?

weewoo
  • 135
  • 1
  • 5
  • 10
  • Did you look at the YAML documentation? You have a ton of options. Here are three possibilities: Make two separate files. Make templates. Use conditions within a single pipeline file. – Daniel Mann Apr 22 '20 at 18:01
  • [The docs](https://learn.microsoft.com/en-us/azure/devops/pipelines/build/ci-build-git?view=azure-devops&tabs=yaml) seem to cover conditional tasks based on branch pretty well. – flyx Apr 22 '20 at 18:05

1 Answers1

1

You could rename the YAML file. It's able create as many build configurations using different yaml files. Just set corresponding trigger for each branch.

Multiple YAML build pipelines in Azure DevOps

If you want to use a single YAML file to cover this. Just as Daniel point out: Use a template parameter as part of a condition

Templates let you define reusable content, logic, and parameters. Templates function in two ways. You can insert reusable content with a template or you can use a template to control what is allowed in a pipeline.

Parameter expansion happens before conditions are considered, so you can embed parameters inside conditions. The script in this YAML file will run because parameters.doThing is true.

parameters:
  doThing: false

steps:
- script: echo I did a thing
  condition: and(succeeded(), eq('${{ parameters.doThing }}', true))

More details please take a look at our official doc here:

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62