1
votes

I want my YAML in one repo RepoA and my code to build in RepoB. How do I configure the YAML to have a CI Trigger on the code RepoB only? Note: these repos are in the same Azure DevOps project. The YAML is in the default branch (master) of RepoA. I've seen that people have had issues with CI triggers if the pipeline is not in the default branch.

Here is the azure-pipeline.yml contents:

trigger: none
resources:
 repositories:
   - repository: RepoB
     type: git
     name: RepoB
     ref: master
     trigger: 
     - master
pool:
  vmImage: 'windows-latest'
steps:
- checkout: RepoB

I also tried removing the line

trigger: none

to see if that would work. The build will then start as soon as I save the yaml, as I would expect, but not when I make a change to RepoB master.

Then I tried the following and many more guesses, but nothing ever enabled a CI Trigger on RepoB. That is, the pipeline never ran when I would make commits to the master branch in RepoB.

resources:
 repositories:
   - repository: RepoB
     type: git
     name: RepoB
     ref: master
     trigger: 
       branches:
        include:
          - master
pool:
  vmImage: 'windows-latest'
steps:
- checkout: RepoB

Here is what I see when I look at the pipelines triggers in the Azure Pipelines UI. Should I see a trigger for RepoB? Pipeline Triggers Screenshot

Update 1:

Although these were not my original settings, I have updated the settings to be as open as possible (no limits). I then tried the following:

  1. I committed a file to the branch in RepoB. No CI trigger occurred.
  2. Deleted the pipeline, and recreated. I committed a file to the branch in RepoB. CI Trigger finally occurred! Pipeline settings screenshot

I believe this is a bug because none of these settings should limit this scenario for the following reasons:

  • Both of the repos are in the same Project.
  • RepoB is explicitly referenced in the pipeline.

Also, you shouldn't have to delete and recreate a pipeline in order for a setting to take effect.

UPDATE 2: I narrowed it down to this Organization or Project level setting: Limit job authorization scope to referenced Azure DevOps repositories

The documentation of this setting does not mention CI Triggers at all, but I do not think that it should affect this scenario regardless, because the repo is referenced explicitly.

Doc References:

I believe this is a bug and I have reported it here: https://developercommunity2.visualstudio.com/t/yaml-pipeline-ci-trigger-for-repository-resource-i/1314241

2

2 Answers

0
votes

Azure DevOps enables some limitation to access to resources by default. Please check if this project enables below options in Project Settings page.

enter image description here Testing in my side that if these options are enabled, this issue can be reproduced. Thus please disable them, and create a new yaml pipeline. The new yaml pipeline should work as expected.

See: Access repositories, artifacts, and other resources for details.

0
votes

I used your yaml and all works (the only difference is that I have main not master branch)

trigger: none
resources:
 repositories:
   - repository: RepoB
     type: git
     name: azure-functions
     ref: main
     trigger: 
     - main
pool:
  vmImage: 'windows-latest'
steps:
- checkout: RepoB

enter image description here

On this screen you have a trigger which fires for a change done on RepoB