Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Pipelines Matrix variables

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?

like image 377
grmbl Avatar asked Jun 24 '19 06:06

grmbl


People also ask

How do you use variables in Azure pipeline?

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.

How do I set environment variables in Azure Pipelines?

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.

How do you use variables in Azure DevOps release pipeline?

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.

How do you pass variables in Azure Pipelines Yml tasks?

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.


Video Answer


1 Answers

You can access the variable like every regular variable:

$(build)

So in your pipeline:

- powershell: Write-Host $(build)
like image 182
Shayki Abramczyk Avatar answered Sep 20 '22 06:09

Shayki Abramczyk