skip to Main Content

We have Azure DevOps Repo, where want to run the pipline as soon as the PR is complete i.e we merge the changes We are using below script:

# Define trigger for the pipeline
trigger:
  branches:
    include:
      - Development
      - QualityAssurance
      - Production
  paths:
    include:
      - '*'
variables:
- group: 'GroupNames'

# Define stages for Dev, QA, and Prod
stages:
  - stage: Development
    displayName: 'Dev'
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/Development'))
    jobs:
      - template: ./deploy-files-template.yaml
        parameters:
          azureSubscription: 'xxx'
          poolname: 'Dev-Ubuntu-20.04'
          vargroup: 'GroupNames'
          inlineScript: 'az storage blob upload-batch -d "$(abcabc)" --account-name "$(abcabc)" -s "$(Build.Repository.LocalPath)/repos/" --account-key "$(abcabc)" --overwrite'


  - stage: QualityAssurance
    displayName: 'QA'
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/pull/*/merge'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/QualityAssurance'))
    jobs:
      - template: ./deploy-files-template.yaml
        parameters:
          azureSubscription: 'Momenttum_QA_SPN-RESRVOIR DATA Project'
          poolname: 'QA-Ubuntu-20.04'
          vargroup: 'QNames'
          inlineScript: 'az storage blob upload-batch -d "$(abcabc)" --account-name "$(abcabc)" -s "$(Build.Repository.LocalPath)/repos/" --account-key "$(abcabc)" --overwrite'

What do we need to do if we want to run the pipeline as soon as a PR is completed,

We tried using pr: but it does not seems to work

can some suggest please?

2

Answers


  1. Add the merge target branch to the branches section of your trigger.

    Login or Signup to reply.
  2. Assuming that you are merging to one of the given branches Development, QualityAssurance, Production,
    The configuration given seems correct, but there are couple things to double-check:

    1. Go to YAML edit -> 3 dots -> Triggers. It opens up a visual editor for continuous integration. Make sure it is not set to override your YAML triggers.
    2. Does not seem like you need the Path property if you want to include all paths anyways, you can try removing it.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search