Reputation: 399
I have a project using multiple repositories:
resources:
repositories:
- repository: one
type: git
name: repo/one
ref: release
- repository: two
type: git
name: repo/two
ref: develop
- repository: three
type: git
name: repo/three
ref: master
How do I get the environment variables for each of these repositories in subsequent steps? For example, I'm interested in the variable $(Build.BuildNumber). Now I only get the variable for the branch from which the yaml project itself is launched.
Upvotes: 0
Views: 3578
Reputation: 2522
The repository
keyword in resources
lets you specify external repositories.
When you check out multiple repositories, some details about the self repository are available as Predefined variables
When you use multi-repo triggers, some of those variables have information about the triggering repository instead. Details about all of the repositories consumed by the job are available as a template context object called resources.repositories
To get the environment variables for each of these repositories you need to define variable:
Example:
resources:
repositories:
- repository: other
type: git
name: MyProject/OtherTools
variables:
tools.ref: $[ resources.repositories['other'].ref ]
steps:
- checkout: self
- checkout: other
- bash: |
echo "Tools version: $(tools.ref)"
Upvotes: 2