Azure DevOps branching and build deploy strategy

635 Views Asked by At

I'm working on the web services project on the Azure DevOps. I have written the yaml pipeline for build and release.

Currently I have kept the yaml file in Develop branch and created the pipeline job from same. As per the practice, we have two branches - Master & Develop. So how I can use single pipeline job for both the branches with auto trigger for develop and schedules base for main branch ? What is the best practice to build and deploy the code to DEV, UAT and PROD environments for Development and Master branches?

1

There are 1 best solutions below

3
Bowman Zhu-MSFT On BEST ANSWER

Update:

You need to make sure the yaml file that the pipeline use exists in both master and Develop, otherwise the commit will not trigger the pipeline at all.

1, pure yaml trigger settings in one pipeline.

azure-pipeline.yml in Master branch:

trigger:
- none

schedules:
- cron: "53 7 * * *" 
  displayName: Master Schedule
  branches:
    include: 
      - master
  always: true 

pool:
  name: default

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

azure-pipeline.yml in Develop branch:

trigger:
- Develop

pool:
  name: default

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

2, pure UI settings in one pipeline.

enter image description here

enter image description here

Original Answer:

You can override the CI trigger of your pipeline.

Pipeline of develop branch:

enter image description here

enter image description here

Pipeline of master branch:

enter image description here

enter image description here

enter image description here