变量yaml中的变量是变量名称
我在管道中有以下任务(Azure DevOps)。第一个任务使用变量$(mySecretName)
从密钥维护中读取秘密,哪个值是secret> secret-name
。第二个任务需要将读取秘密的价值传递给ARM:
- task: AzureKeyVault@2
displayName: 'Read secret'
inputs:
azureSubscription: $(mySubscription)
KeyVaultName: $(myKeyVault)
SecretsFilter: $(mySecretName)
RunAsPreJob: false
- task: AzureResourceGroupDeployment@3
displayName: 'Use secret value'
inputs:
resourceGroupName: $(myResourceGroup)
location: $(myLocation)
azureResourceManagerConnection: $(mySubscription)
templateLocation: 'Linked artifact'
csmFile: '$(Pipeline.Workspace)/cd-template.json'
overrideParameters: >
-secretValue "$($(mySecretName))"
deploymentMode: 'Incremental'
in Line -secretValue“ $($(mySecretName))”
我试图以这种方式解决,但显然它不起作用:$(mySecretName)
- > $(secret -name)
- > 秘密值
。如果我使用$(秘密名称)
它将起作用,但是我需要使用$(mySecretName)
,因为该名称会根据环境而更改。
是否有任何解决方案可以使我获得变量的值哪个名称是另一个变量的值?
I have following tasks in a pipeline (Azure DevOps). First task read a secret from a KeyVault using a variable $(mySecretName)
which value is secret-name
. Second task needs to pass the value of the read secret to a ARM:
- task: AzureKeyVault@2
displayName: 'Read secret'
inputs:
azureSubscription: $(mySubscription)
KeyVaultName: $(myKeyVault)
SecretsFilter: $(mySecretName)
RunAsPreJob: false
- task: AzureResourceGroupDeployment@3
displayName: 'Use secret value'
inputs:
resourceGroupName: $(myResourceGroup)
location: $(myLocation)
azureResourceManagerConnection: $(mySubscription)
templateLocation: 'Linked artifact'
csmFile: '$(Pipeline.Workspace)/cd-template.json'
overrideParameters: >
-secretValue "$($(mySecretName))"
deploymentMode: 'Incremental'
In line -secretValue "$($(mySecretName))"
I'm trying to resolve in this way but apparently it does not work: $(mySecretName)
-> $(secret-name)
-> secret value
. If I use $(secret-name)
it will work, but I need to use $(mySecretName)
because the name will change depending on the environment.
Is there any solution that allows me to get the value of a variable which name is the value of another variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从您的yaml示例中,您使用的是嵌套变量
$($(mySecretName))
。该管道中尚未支持它。要达到您的要求,您可以使用扩展名来使用可变设置的任务:可变工具箱。
您可以在AzureresourceGroupDeployment任务之前添加变量设置任务。
例如:
From your YAML sample, you are using nested variables
$($(mySecretName))
. It is not yet supported in the pipelines.To achieve your requirement, you can use the Variable Set task from extension: Variable Toolbox.
You can add the Variable Set task before the AzureResourceGroupDeployment task.
For example:
您可能无法使用嵌套变量,但是可以在变量中嵌套a parameter 。因此,如果将
mySecretName
作为参数传递,则可以执行此操作:这显然是因为前处理器在执行前替换了参数值。
You may not be able to use nested variables, but you can nest a parameter in a variable. Thus, if you pass
mySecretName
as a parameter, you can do this:This is apparently because a pre-processor substitutes the parameter value before execution.