I am reading this doc: https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops
According to the link above, we can have multiple projects in one pipeline. So I have something like this:
trigger:
- none
resources:
repositories:
- repository: repo1
type: git
name: org/repo1
ref: test_multi_repo_pipeline
trigger:
- test_multi_repo_pipeline
- repository: repo2
type: git
name: org/repo2
ref: test_multi_repo_pipeline
trigger:
- test_multi_repo_pipeline
stages:
- stage: Build_and_Deploy
pool:
name: 'myAgent'
jobs:
- job: Build
condition: always()
steps:
- checkout: repo1
displayName: 'repo1'
- checkout: repo2
displayName: 'repo2'
- script: dir $(Build.SourcesDirectory)
displayName: 'Build.SourcesDirectory'
- script: |
npm run build:project_win_dev
displayName: Building the project...
- script: |
npm run test:coverage
displayName: Testing the skill...
- script: dir $(Build.SourcesDirectory)
displayName: 'Build.SourcesDirectory'
name: Test
So when I execute this yaml I get the next output on this task "Build.SourcesDirectory":
Directory of E:\Builds_VNext\Agent2_Builds\3046\s
03/24/2022 11:24 AM <DIR> .
03/24/2022 11:24 AM <DIR> ..
03/24/2022 11:24 AM <DIR> pipelines
03/24/2022 11:24 AM <DIR> repo1
03/24/2022 11:24 AM <DIR> repo2
0 File(s) 0 bytes
5 Dir(s) 878,801,965,056 bytes free
So once the "Build" task gets executed it fails because it gets executed in the root rather than in the specific project which I made the commit. So I was wondering if there is a way to know that if I made the commit in the project repo1, then the build gets done under the folder repo1 and if I made the change on repo2 then the build gets done inside repo2 folder
Thanks in advance for your help.
Greetings
So, you could write a conditional to determine which repo you're editing. But, I'd advise against it. You'd have to query the git history and detect changes.
The path of lease resistance is to build both every time. You'd just need to update your code to
cd
to the correct folder before building: