In my pipeline template, I am checking out code from 2 different repos:
resources:
repositories:
- repository: DeploymentRepo
type: git
name: MyProject/AWS.Deployment
...
steps:
- checkout: self
- checkout: DeploymentRepo
Which creates 2 directories. One is named for the "self" repo and the other for the "DeploymentRepo". I used $(Build.Repository.Name)
to reference the name of the "self" repo for the path. Is there a way to reference the other repo directory? I can also use $(Build.Repository.LocalPath)
, but it only references the "self" repo. I want to reference the path to the "DeploymentRepo" using a variable. Do AZ pipelines support such a notion? I have read through this several times, but I see nothing obvious.
2
Answers
No there isn’t such a variable. As suggested in the comments, using
$(Build.SourcesDirectory)/DeploymentRepo
or$(Pipeline.Workspace)/s/DeploymentRepo
are the variables mostly used for this.When you checked multiple repos in the same jobs of a YAML pipeline, each repo generally will be checked out to the path "
$(Build.SourcesDirectory)/<repo name>
" by default.For the self repo where the YAML is hosted, you can use the predefined variable "
Build.Repository.Name
" to get the repo name.For each resource repos, you can use the repository resource variable "
resources.repositories.<Alias>.name
" to get the repo name.Note: For repository resource variables, you cannot directly reference them on the pipeline tasks using the expression like as "
$(resources.repositories.<Alias>.name)
", you need to first map them as the pipeline variables, and then reference the pipeline variables.See below example.