Assuming that all your repos are in the same organization, and there is no policy or security blocking checking out repos between project, then you could achieve on two ways
1. Using git submodule update
In this method we are using System.AccessToken
to authenticate against https
repositories specified in .gitmodules
file. BTW. all submodules MUST be on HTTPS!
pool :
vmImage : "ubuntu-latest"
stages :
- stage : Build
jobs :
- job : Build
steps :
- script: |
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" \
submodule update --init --recursive
displayName: Fetch Submodules
2. Using repositories
task
Below pipeline will checkout repositories and mount them at the path locations. Path /s
is important because, it will checkout repo into code working directory, and if Project A file system contains libs/repo-one/
and libs/RepoTwo/
paths, then source code of Project B will be mounted there.
pool :
vmImage : "ubuntu-latest"
resources:
repositories:
- repository: repo-one
name: Project B/repo-one
type: git
- repository: RepoTwo
name: Project B/Repo Two
type: git
stages :
- stage : Build
jobs :
- job : Build
steps :
# Project A
- checkout: self
submodules: false
path: "s/"
# Project B
- checkout: repo-one
path: "s/libs/repo-one/"
- checkout: RepoTwo
path: "s/libs/RepoTwo/"
- script: |
ls -la .
ls -la libs/repo-one
ls -la libs/RepoTwo
displayName: Debug File System