如何在Azure发布管道的Azure Powershell任务中使用链接变量组中的秘密变量?

时间:2020-07-28 22:33:41

标签: azure-devops azure-pipelines azure-powershell azure-pipelines-release-pipeline

我有一个使用Azure DevOps中的GUI构建的Azure 发布管道。有一个阶段具有一个链接的变量组(发布范围),该变量组中有一个秘密变量。该阶段具有一个代理作业,该作业具有运行脚本文件的Azure Powershell任务。该脚本文件使用语法$env:MYSECRETVARIABLE引用秘密变量,但该值为null。当我添加运行Get-ChildItem -Path Env:\的用于调试的Azure Powershell任务时,可以看到变量组中的所有非秘密变量都已映射,而秘密变量未映射。我在这里做什么错了?

1 个答案:

答案 0 :(得分:3)

我测试过在天蓝色的powershell任务中将秘密变量保存到变量组中,只需使用$(varibaleName)的语法即可。

使用内联脚本进行测试:

enter image description here

enter image description here

enter image description here

使用脚本文件进行测试:

enter image description here

enter image description here

enter image description here