I have a project in Azure that has many repositories. All of the repositories need to run with the same pipeline, so I’m looking for a way to define the repository name as a variable.
Here’s an example of what I’m trying to achieve:
trigger:
- master
pool:
name: 'xxxx'
variables:
repoName: 'repoA'
resources:
repositories:
- repository: repo
type: git
name: '50aa1c1f-21f0-4c61-8d85-d83218e705c9/$(repoName)'
steps:
- checkout: self
- checkout: repo
- script: echo Hello, world!
displayName: 'Run a one-line script'
Does anyone have any idea how to get this to work?
2
Answers
It’s not supported to use variable as the repository name in Yaml resource. Please check the doc below:
If you would like to checkout multiple repo, and define reponame in variable,
as an alternative
, you can usecheckout
task.It’s mentioned in doc:
Please check similar ticket for the details.
I’d like to suggest a different approach:
templates).
The base pipeline will ensure a standard structure for your pipelines, and will prevent code duplication.
Yes, there will be multiple pipelines to manage. But on the other hand, you don’t need to have complicated logic to determine which repository/application is being used, etc. Also, it will be much easier to customize agent pools, resources, triggers, CRON schedules for each one, if required.
Example
Base pipeline (shared templates repository):
Pipeline for repository/application
foo
:Pipeline for repository/application
bar
: