Michael George
Michael George

Reputation: 737

Azure Devops build pipeline: CI triggers not working on PR merge to master when PR set to none

Need to trigger CI build job when a PR is merged to master (only when change is inside ./rel/* path) but not have CI build triggered when the Pull Request (PR) is created. So I have the trigger config as below.

trigger:
    branches:
        include:
        - master
    paths:
        include:
        - ./rel/*

pr: none # will disable PR builds (but not CI builds)

But it fails to trigger CI build when pr: none is added. If pr: none is removed, The Job is getting triggered for both PR and a merge to master. I would only need the job/CI build to run on a merge to master.

Upvotes: 4

Views: 4630

Answers (2)

Michael George
Michael George

Reputation: 737

Solved! This works now.

trigger:
    branches:
        include:
        - master
    paths:
        include:
        - ./rel/*

pr: none # will disable PR builds (but not CI builds)

Also you can configure / override using the classic azure devops UI from Triggers.

Ref : https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=classic#ci-triggers

PR trigger

CI trigger

Upvotes: 2

krb224
krb224

Reputation: 345

The paths filter in the YAML is looking at paths in your repository file structure, not the branch path. To have it only trigger on rel branch, replace the master under the include branches with ./rel/* (or the correct value).

We have a more defined pipeline that runs unit tests on PR and then only packages for release on merge into the master branch. We do this by having our trigger set to the master branch and using conditions for each stage in the multi-stage pipeline. Check those out as well.

Upvotes: 2

Related Questions