[英]Azure DevOps: Substitute variables with variables
I have Azure key vault
, where in I have set of keys written我有
Azure key vault
,其中我有一组密钥
dev-key
stg-key
prd-key
Now I have downloaded the key dev-key
in azure DevOps pipeline
.现在我已经在
azure DevOps pipeline
中下载了密钥dev-key
。 I want to map the downloaded variable to the 'constant' variable called 'key'
, as this variable is being used in deployment yaml files(I am replacing this variable in token replace step)我想将下载的变量 map 到名为
'key'
的 'constant' 变量中,因为此变量正在部署 yaml 文件中使用(我在令牌替换步骤中替换此变量)
Currently I am mapping this variable in pipeline variables like,目前我正在将此变量映射到管道变量中,例如,
tenant: dev
key: $($(tenant)-key)
However the value is set in deployment yaml file to the key is $(dev-key)
.但是,该值是在部署 yaml 文件中设置的,密钥为
$(dev-key)
。 Can we substitute variables with variables in Azure DevOps
?我们可以用
Azure DevOps
中的变量替换变量吗?
Resolving of nested variables is currently not supported.当前不支持解析嵌套变量。
See: https://developercommunity.visualstudio.com/content/problem/479258/nested-release-variables-fail-to-be-recognized.html请参阅: https://developercommunity.visualstudio.com/content/problem/479258/nested-release-variables-fail-to-be-recognized.html
An alternate solution is the following setup:另一种解决方案是以下设置:
Key Vault
per environmentKey Vault
Stage
per environmentStage
Key Vault
Key Vault
中的密钥名称始终相同Scope
Scope
Stage
access the variable as declared in the Variable group
Stage
的每个任务中访问Variable group
With this configuration, you can re-use the same secret key in tasks and the actual values are resolved by the scope of the variable group per Stage
as you define.使用此配置,您可以在任务中重复使用相同的密钥,实际值由您定义的每个
Stage
的变量组的 scope 解析。
I have managed this with assigning the scope to the variables.我通过将 scope 分配给变量来解决这个问题。
variable value scope
key $(dev-key) dev
key $(stg-key) stg
key $(prd-key) prd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.