I have two Repos, Repo A
(with YAML Pipeline A
) and Repo B
(dependency of Repo A
as well as a stand-alone product) both in the same project in Azure DevOps. Now I want to run Pipeline A
with any changes from both repos. Therefore I used Multi-repo triggers, but this only works on the master branch of Repo A
.
We have multiple release branches in both repos and I want to configure the pipeline to run a build of the release branch of Repo A
whenever there are changes in the corresponding Release branch of Repo B
. I also want to run the pipeline whenever there are changes in the master branches.
I have tried to add this to the master branch of Repo A
:
resources:
repositories:
- repository: self
type: git
ref: refs/heads/master_A
trigger:
branches:
include:
- refs/heads/master_A
- repository: Repo B
type: git
name: Repo B
ref: refs/heads/master_B
trigger:
branches:
include:
- refs/heads/master_B
and this to the Release branch of Repo A
:
resources:
repositories:
- repository: self
type: git
ref: refs/heads/Release-A
trigger:
branches:
include:
- refs/heads/Release-A
- repository: Repo B
type: git
name: Repo B
ref: refs/heads/Release-B
trigger:
branches:
include:
- refs/heads/Release-B
But that way, it only runs when there are changes in master_A
, Release-A
or master_B
but it does not run when there are changes in Release-B
Based on your YAML sample, I can reproduce the same situation. It only runs when there are changes in master_A, Release-A or master_B but it does not run when there are changes in Release-B.
This is an expected behavior.
Refer to this doc: Mutiple Repo Trigger
When a pipeline is triggered, Azure Pipelines has to determine the version of the YAML file that should be used and a version for each repository that should be checked out. If a change to the self repository triggers a pipeline, then the commit that triggered the pipeline is used to determine the version of the YAML file. 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.
If it is a commit to the self repository, it will trigger the pipeline based on the YAML file corresponding to the submission confirmation. So the master_A, Release-A can trigger the Pipeline.
But for the resource repo, it determines the YAML version to use based on the Self Repo's Default branch. Therefore it will trigger the pipeline based on the Repo resource branch(master_B) set in master_A.
You can navigate to Azure Repo -> Branches to check the Default Branch.
If you need to use Release_B branch to trigger the Pipeline, you need to change the Default Branch to Release_A.
Here is a summary:
When you set the Default Branch to master_A, the following branches can trigger the pipeline.
master_A Release-A master_B
When you set the Default Branch to Release_A, the following branches can trigger the pipeline.
master_A Release-A Release-B