Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To transfer variables to a pipeline variable, you can use the Set Pipeline Variable task in your pipeline. This task allows you to set or update the value of a specific variable in the pipeline as it runs.

To transfer variables to the pipeline variable, you need to add variables to the variables section of your pipeline YAML file. Then, you can access those variables in your pipeline using the ${{ variables.<variable-name> }} syntax.

For example, to transfer a variable named "myVar" to a pipeline variable named "pipelineVar", you can use the following code in your YAML file:

variables:
  myVar: 'hello world'

steps:
- script: echo ${{ variables.myVar }}
  displayName: 'Print myVar'
- task: AzureCLI@2
  inputs:
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: |
      pipelineVar=${{ variables.myVar }}
      echo "Pipeline variable value: $pipelineVar"
  displayName: 'Set pipelineVar'

In this example, the first step prints the value of the "myVar" variable, while the second step sets the value of the "pipelineVar" pipeline variable to the value of "myVar".