MC Emperor
MC Emperor

Reputation: 23017

How to move 'resources → containers' to a template in Azure Pipelines YAML file?

We are using multiple Azure pipelines to deploy services, using YAML code as definitions for the pipelines.

Now each of the pipelines may run their jobs in build containers defined in the resources section of the YAML file:

resources:
  containers:
  - container: some-container
    image: myacr.azurecr.io/some-container:latest
    endpoint: myacr
  - container: another-container
    image: myacr.azurecr.io/another-container:latest
    endpoint: myacr
  - ...

Now, as multiple pipelines use these containers, managing these becomes tedious, as their number grows.

Is there some way to include these in a template or somehow include these in the YAML file?

I tried to use a template like this:

pipeline-1.yml:

resources:
  containers:
  - template: containers.yml

containers.yml:

containers:
- container: some-container
  image: myacr.azurecr.io/some-container:latest
  endpoint: myacr
- container: another-container
  image: myacr.azurecr.io/another-container:latest
  endpoint: myacr

But the pipeline runner does not accept that, it emits "Unexpected value: template".

Upvotes: 1

Views: 596

Answers (1)

Felix
Felix

Reputation: 1162

According the doc: Resources: containers, We do not support the keywords 'template' in the container resource. And also, we recommend you can create a suggestion ticket on the Developer Community:https://developercommunity.visualstudio.com/report?space=21&entry=suggestion

Upvotes: 0

Related Questions