Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Azure DevOps: How to pass on a variable to a template read from Library variable group

I have a variable group defined in pipeline > Library > variable group > called ‘template-variable-group’

Defining Variable Group in Azure DevOps

All that I am trying to accomplish here is to pass on the value of the variable my-temp-var (in this case as you can see its value is my-template-value) to a template from the yaml file.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have a yaml based pipeline as follows.

variables:
- group: template-variable-group

name: $(date:yyyyMMdd)$(rev:.r)

stages:
  - stage: Build

    jobs:
      - job: buildWebApp
        displayName: Build Release pipeline for Discount Service on Master branch

        steps:
        - script: |
            echo Here we go
          displayName: 'Command Line Script'

        - template: template.yaml
          parameters:
            variableToTemplate: ${{variables['my-temp-var']}}

And the template.yaml file is as follows.

parameters:
  variableToTemplate:

steps:

- task: CmdLine@2
  inputs:
    script: |
      echo Hello Hello Hello Hello Hello Hello
      echo ${{ parameters.variableToTemplate }}
  displayName: 'Run a two-line script'

I am not able to do that.

pipeline with a template

As you can see, that value is not reaching the template. What am I missing.

I saw this SO Answer but did not seem to be of help.

>Solution :

You can just pass it like a regular variable:

$(my-temp-var)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading