azureazure-devops

Azure Pipeline not triggered by changes to other than self repository


I have two repositories and both are in same project of ADO: one is at the top level (It also include pipeline yaml), and the other is defined as a submodule. I want to trigger a pipeline whenever an update is pushed to either the main repository or any of the repositories declared as resources(submodule mentioned here).

I tried below code but it only trigger on changes in self or if i run manually.

trigger: 
- main

pool:
  name: 'myselfhostedagent'

resources:
  repositories:
  - repository: sub_repo
    type: git
    name: test/sub_repo
    ref: master
    trigger:
    - master

steps:
- checkout: self
- checkout: sub_repo
- script: |
      echo $(Build.Repository.Name)
      echo $(Build.SourceBranch)
      dir $(Build.SourcesDirectory)

Troubleshooting:

  1. I defined self trigger to none but no success
  2. I created pipeline in sub_repo and it getting trigger properly
  3. As per docs "If a change to any other repository resource triggers the pipeline, then the latest version of YAML from the default branch of self repository is used." I verified that my self repo has defined main as default branch.
  4. After manual run if i check changes section of last pipeline run instance it shows both current pipeline and sub_repo changes

Any tips to resolve this or any way to verify from logs that as soon as i do push in sub_repo how AzureDevOps handle it.

Edit1: In response to @Alvin Zhao

if the above YAML contents are from the pipeline.yml in main branch of the TopRepo?

Yes its from TopRepo

And for the sub_repo resource, the actual project name is test and the actual repo name is sub_repo?

Project name is test and i modified repo name for asking question.

What is the default branch of sub_repo by the way.

For TopRepo default branch is main, For sub_repo its master

Please double check the Trigger settings in pipeline WEB UI if the option to Override the YAML continuous integration trigger from here was checked

It was not checked i did now, but results are same no success

enter image description here


Solution

  • Based on the description, my pipeline referencing the azure-pipelines.yml in the main branch of self TopRepo was able to get trigged by the commits pushed to the main branch of TopRepo and to the master branch of sub_repo in test project.

    Here is the sample for your reference to check and compare.

    Image

    enter image description here