Azure管道运行时评估的变量传递了参数

时间:2020-05-18 08:03:03

标签: azure-devops azure-pipelines

我有一个AzurePowerShell脚本(powershell / gettenants.ps1),用于设置承租人变量的值。

以下bash任务成功回显了新值,但以下模板获得了默认值(在脚本顶部设置)。注意在指定模板参数值时,我使用表达式语法。

有什么想法我做错了吗?


variables:
 tenants: "default value"

 - stage: Build_Shared_Update
   jobs:
   - job: Get_all_Tenants_Info
     pool:
       vmImage: 'windows-latest'
     steps:
       - checkout: self
         fetchDepth: 1
       - task: AzurePowerShell@4
         inputs:
           azureSubscription:  'Product Subscription(Guid)'
           targetType: 'filePath'
           scriptPath: powershell/gettenants.ps1
           errorActionPreference: 'stop' 
           azurePowerShellVersion: 'latestVersion'

       - task: Bash@3
         inputs:
           targetType: 'inline'
           script: echo $(tenants)
   - template: pipeline-templates/shared-infrastructure-plan.yml  # Template reference
     parameters:
       tenants: ${{variables.tenants}}

在模板中,参数的引用如下:

-out=sharedplan -var=list_of_tenants=${{parameters.tenants}}

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

变量不在范围内!

值得一提的是,“有很多东西要学习”也可以识别出这一点:)