如何在Azure发布管道的Azure Powershell任务中使用链接变量组中的秘密变量? [英] How can you use secret variables from a linked variable group in an Azure Powershell task in an Azure Release pipeline?

查看:55
本文介绍了如何在Azure发布管道的Azure Powershell任务中使用链接变量组中的秘密变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an Azure Release pipeline that I've built using the GUI in Azure DevOps. There is a stage that has a linked variable group (Release scope) with a secret variable in the variable group. The stage has an agent job with an Azure Powershell task that runs a script file. That script file references the secret variable using the syntax $env:MYSECRETVARIABLE but the value is null. When I add an Azure Powershell task for debugging that runs Get-ChildItem -Path Env:\, I can see that all the non-secret variables in the variable group are mapped but the secret variable is not. What am I doing wrong here?

推荐答案

我测试过在天蓝色的powershell任务中获取变量组中的秘密变量,只需使用 $(varibaleName)的语法即可工作.

I tested to get the secret variable in the variable group in azure powershell task, just use the syntax of $(varibaleName) to work.

使用内联脚本进行测试:

Test with inline script:

使用脚本文件进行测试:

Test with Script File:

这篇关于如何在Azure发布管道的Azure Powershell任务中使用链接变量组中的秘密变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆