I'm working with a repository (A
) that contains a different repo as a sub-module (B
). The contents of repo B
is used by the logic in A
, and needs to be updated regularly.
I currently have an Azure build pipeline which is triggered whenever a push to A
occurs. I've also made sure that the artifact created by the build contains data from B
. This is defined in Yaml; in short:
trigger:
branches:
include:
- master # <-- Trigger a build when the branch 'master' is pushed to!
I can see in the documentation that it is possible to connect this trigger to different branches and / or paths in the same repository.
The problem is that as a sub-module, Repo B
is really a completely separate repo, which is pushed to quite separately from A
. This means that even though B
is updated when A
is pulled during the build pipeline, pushes to B
do not automatically register as pushes to A
, so the build is not triggered.
I would be great if I could do something similar to the following to make up for this...
trigger:
branches:
include:
- master
- my-other-repo-B # <-- Trigger a build when B is pushed to!
... but this does not seem to be possible, as far as I can tell.
My current best option seems to be to create a separate build for B
, and then add an extra trigger in Azure DevOps which initiates the main build whenever that has run. That should in theory work, but I would really prefer to control both triggers for the build in the same place, if possible.
Are there any other good / clean ways to achieve this?
You can use the repository resource to trigger a pipeline when push occurs on another repository.
RepoA
and RepoB
are in the same project, you can set up like as below in the YAML file of your build pipeline.resources:
repositories:
- repository: subRepos # The ID of the repository. You can customize it here.
type: git
name: RepoB # The actual name of the repository.
trigger: # CI trigger
batch: true
branches: # branch filter
. . .
paths: # path filter
. . .
tags: # tag filter
. . .
RepoB
is in a different project (e.g. ProjB
) within the same organization, you can set up like as below in the YAML file of your build pipeline.resources:
repositories:
- repository: subRepos
type: git
name: ProjB/RepoB
trigger:
batch: true
branches:
. . .
paths:
. . .
tags:
. . .
For more details, you can reference the following documents: