Can somebody explain me how I can access the variable build
from this matrix job setup?
parameters:
# job ---
...
configurations: [Release, Debug]
...
jobs:
- job: nightly
displayName: Nightly
strategy:
matrix:
${{ each configuration in parameters.configurations }}:
${{ configuration }}:
build: ${{ configuration }} # !PARAMETER/VARIABLE FOR JOB SET HERE!
${{ if ne(configuration, 'Release') }}:
dependsOn: Release
pool:
vmImage: ${{ parameters.image }}
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
steps:
- powershell: Write-Host ${{ parameters.build }}
displayName: 'Write Configuration: ${{ parameters.build }}'
The jobs powershell task is showing Write Configuration:
so the variable is null?
Set variables in pipeline. In the most common case, you set the variables and use them within the YAML file. This allows you to track changes to the variable in your version control system. You can also define variables in the pipeline settings UI (see the Classic tab) and reference them in your YAML.
There are 3 ways to get an environment variable value on your build server: Set the value on the build machine. Set the value in the YAML build script. Set the value in Azure DevOps for the build pipeline definition.
You define and manage these variables in the Variables tab in a release pipeline. In the Pipeline Variables page, open the Scope drop-down list and select "Release". By default, when you add a variable, it is set to Release scope. Share values across all of the tasks within one specific stage by using stage variables.
Passing variables between tasks in the same jobSet the value with the command echo "##vso[task. setvariable variable=FOO]some value" In subsequent tasks, you can use the $(FOO) syntax to have Azure Pipelines replace the variable with some value.
You can access the variable like every regular variable:
$(build)
So in your pipeline:
- powershell: Write-Host $(build)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With