Azure Pipelines矩阵变量

时间:2019-06-24 06:43:30

标签: azure azure-devops continuous-integration yaml azure-pipelines

有人可以解释我如何从此矩阵作业设置访问变量build吗?

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 ${{ paramteres.build }}
        displayName: 'Write Configuration: ${{ parameters.build }}'

jobs powershell任务显示Write Configuration:,因此变量为null?

1 个答案:

答案 0 :(得分:0)

您可以像访问每个常规变量一样访问该变量:

$(build)

因此在您的管道中:

- powershell: Write-Host $(build)