Kirsten
Kirsten

Reputation: 18168

How do I stop my build pipeline from running when I commit other branches than master?

I want my YAML build pipeline to only buid if I commit to master. Currently a commit to any branch will trigger a build.

I have Continuous Integration Enabled. The default branch for manual and scheduled builds is master. Under triggers I have Override the YAML continuous integration trigger unchecked In the Triggers section

In the YAML I have

trigger:
  braches:
    include: 
    - master

pool:
  vmImage: 'windows-latest'

I thought that by only having masster mentioned in the trigger section then only a commit to master should trigger the pipeline. However any commit will trigger it.

Update

I also tried excluding master but the pipeline still runs.

trigger:
   branches:
     include:
     - azure-pipelines-ubuntu
     exclude:
       - master

I see that both pipelines are running the YAML in my linux branch and yet when I edit the first pipeline, by clicking the three dots and selecting edit, it opens the YAML in master

Pipelines

When I try running my Linux pipeline manually I get an error

Encountered error(s): Could not find valid pipeline YAML file for this branch/tag

I then select the correct branch and can run it.

I also see a message when viewing the Run.

Some recent issues detected related to pipeline triggers

recent issues message

When I click View Details I see a message

Configuring the trigger failed, edit and save the pipeline again

Doing that does not help.

Update

I edited a file in the azure-pipelines-linux branch via Visual Studio and committed. The resulting commit graph is commit graph

The azure-pipelines-linux.yml only exists in the azure-pipelines-linux branch.

Update

In the UI both pipelines show as being for the azure-pipelines-ubuntu branch. Yet when I edit the pipeline from Devops the correct yml loads to edit. pipelines

Editing the first pipeline from DevOps

First Pipeline

Editing the second pipeline from DevOps

Second Pipeline

Update When I edit the YAML I can see the branch I want in the combo box choosing branck when editing yml

Upvotes: 0

Views: 133

Answers (1)

Bright Ran-MSFT
Bright Ran-MSFT

Reputation: 13944

I noticed that you have two pipelines:

  • A pipeline defined by the azure-pipelines.yml file.
  • Another pipeline defined by the azure-pipelines-ubuntu.yml file.

If you want the pipeline of azure-pipelines.yml file runs only for master branch, you can:

  • Configure the CI trigger like as below in the azure-pipelines.yml file.
    trigger:
       branches:
         include:
         - master
    
  • Ensure the azure-pipelines.yml file with this CI configuration is existing in master branch.
  • For other branches, the azure-pipelines.yml file can be not existing. If exists, ensure it has the same configuration of CI trigger.

Similarly, if you want the pipeline of azure-pipelines-ubuntu.yml file runs only for azure-pipelines-ubuntu branch, you can:

  • Configure the CI trigger like as below in the azure-pipelines-ubuntu.yml file.
    trigger:
       branches:
         include:
         - azure-pipelines-ubuntu
    
  • Ensure the azure-pipelines-ubuntu.yml file with this CI configuration is existing in azure-pipelines-ubuntu branch.
  • For other branches, the azure-pipelines-ubuntu.yml file can be not existing. If exists, ensure it has the same configuration of CI trigger.

Upvotes: 1

Related Questions