0

We have large application we deploy from ADO using classic pipelines. In the process of converting over to yaml. The application is made up of multiple smaller apps which are deployed individually into multiple environments. The environments are being added and removed as projects commence and complete so it is not a fixed list.

The problem is we will need to update 20-30 yamls each time the list changes.

We are using templates to reuse code extensively. The question is - can we have a master list of environments and parameters that can be read into each deployment at deploy time?

Here is a example snippet of the pipeline code we use - calls out to our deployment yaml for each environment/stage:

extends:
  template: pipelines/main.yml@templates
    deployStages:
      - template: stages/deploy.yml@templates
        parameters:
          dependsOn: buildContainer
          deploySteps:
            - template: ./app-deploy.yml
              parameters:
                serviceConnection: test
          environment: test
          poolName: 'Azure Pipelines'
          runIfNotMainOrMaster: ${{ eq(parameters.action, 'Deploy') }}
          variableGroup: 'test'
      - template: stages/deploy.yml@templates
        parameters:
          dependsOn: deploy_test
          deploySteps:
            - template: ./app-deploy.yml
              parameters:
                serviceConnection: staging
          environment: stage
          poolName: 'Azure Pipelines'
          variableGroup: 'staging'
      - template: stages/deploy.yml@templates
        parameters:
          dependsOn: deploy_stage
          deploySteps:
            - template: ./app-deploy.yml
              parameters:
                serviceConnection: production
          environment: prd1
          poolName: 'Azure Pipelines'
          variableGroup: 'prd1'

etc.

1 Answer 1

0

Create a variable group for each environment, containing the environment-specific parameter values.

In your parameterized templates, reference the variables from the respective variable group. These templates can be reused across different deployments.

In your individual pipeline YAML files, include the parameterized templates and link them to the appropriate variable group based on the deployment environment.

When you trigger a pipeline for a specific environment, Azure DevOps will automatically inject the values from the corresponding variable group into the templates. This allows you to achieve dynamic configuration without having to manually modify YAML files each time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.