skip to Main Content

I have a pipeline that has a section like this that lists the pipelines that would trigger the pipeline.

resources:
  # List all the microservice pipelines to be watched plus infrastructure, the pipeline name is the name
  # of the stack.  Note template-maven and template-gradle are not to be part of this build.
  pipelines:
    - pipeline: auth
      project: services
      source: auth
      branch: master
      trigger:
        branches:
          include:
            - master
    - pipeline: ai
      project: services
      source: artificial-intelligence
      branch: master
      trigger:
        branches:
          include:
            - master
    - pipeline: ui
      project: frontend
      source: ui CI
      branch: master
      trigger:
        branches:
          include:
            - master

I then have a job with the following steps (because deployment pulls all files, I just need one folder from each pipeline

      - job: publishDeploymentPipelineFiles
        condition: not(canceled())
        steps:
          - checkout: none
          - download: auth
            artifact: drop
          - download: ai
            artifact: drop
          - download: ui
            artifact: drop

What I am hoping for is some form of template that does

  steps:
    - checkout: none
    - template: pull-deployment-manifests.yml
      parameters:
        sources:
        - project: services
          source: auth
          stackName: auth
        - project: services
          source: artificial-intelligence
          stackName: ai
        - project: frontend
          source: ui CI
          stackName: ui

Which only lists the project and CI pipeline and create the appropriate pipeline ID from stackName and create the resources and the steps.

My workaround right now is to create a project that takes a CSV containing those items and generating the azure-pipelines.yml

2

Answers


  1. As far as I know you can’t dynamically create resources. So you create this

      steps:
        - checkout: none
        - template: pull-deployment-manifests.yml
          parameters:
            sources:
            - project: services
              source: auth
              stackName: auth
            - project: services
              source: artificial-intelligence
              stackName: ai
            - project: frontend
              source: ui CI
              stackName: ui
    

    and run checkout inside the template unless you defined resources with those names on root level.

    As documentation says here:

    Resources are defined at one place and can be consumed anywhere in your pipeline.

    Login or Signup to reply.
  2. Sure you can set up a template with resources, and use this template in a YAML pipeline. You can reference "Extend from a template with resources".

    However, please note that if you have defined resources and steps in the template, you can’t use it under the steps key in the YAML pipeline. You should use the extends key to extend the resources from the template, just like as the example shows in the document.

    You may need to defined all the required steps in the template, or use the steps from other step template into the template.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search