'How can i include folders from other repos when running a pipeline in Azure Devops
I have a repo called REPO A and have created a YAML pipeline in here but I also have some code in REPO B which I need to use in this pipeline
In YAML how can tell the pipeline in REPO A to use files/folders from REPO B?
Im a newbie to this so can you please keep it simple?
resources:
repositories:
- repository: automation
type: git
name: MYORG/ automation
ref: develop
endpoint: YourEndpoint
steps:
- checkout: self
path: "s/Source" : ***>>>>>> what should this be??***
- checkout: automation
Solution 1:[1]
You should check out multiple repositories on your YAML pipeline. You can define a new resource repository and checkout this repository along with your source (the one that triggers the pipeline).
resources:
repositories:
- repository: devops_sf
type: github
name: Organization/Repository
ref: master
endpoint: YourEndpoint
steps:
- checkout: self
path: "s/Source"
- checkout: devops_sf
Then you will be able to access your repositories under
$(Pipeline.Workspace)/s/Repository
$(Pipeline.Workspace)/s/Source
Multi repo checkout for Azure DevOps:
https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops
Solution 2:[2]
ok simply put at the top of the yaml i added
> resources:
> repositories:
> - repository: automation
> type: git
> name: name of yourpoject/name of repo you want to use
> ref: whatever branch of that repo(under repository above) you want to use
THEN!! under steps in the YAML (if you havent one you need to add it!)
> steps:
> - checkout: self
> - checkout: your repository you want to use as above
Also if you use npm to run a task you need to add the below as well to not get any file not found errors! a common error if you dont add the below code is : npm WARN saveError ENOENT: no such file or directory, open '/home/vsts/work/package.json
The below code is put in the -Task section
> > npm install
> > displayName: 'a task using npm'
> > workingDirectory: '$(Build.SourcesDirectory)/your repository you want to use as above
ALSO be aware of indentation when inserting code in YAML it's annoying and a pain if you havent got the indentation right it gives you errors just tab until they go away
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | GeralexGR |
| Solution 2 |
