Azure DevOps:用变量替换变量
Azure DevOps: Substitute variables with variables
我有Azure key vault
,其中我写了一组键
dev-key
stg-key
prd-key
现在我已经在 azure DevOps pipeline
中下载了密钥 dev-key
。我想将下载的变量映射到名为 'key'
的 'constant' 变量,因为这个变量正在部署 yaml 文件中使用(我在令牌替换步骤中替换了这个变量)
目前我正在将此变量映射到管道变量中,例如
tenant: dev
key: $($(tenant)-key)
但是在部署 yaml 文件中设置的值是 $(dev-key)
。
我们可以用 Azure DevOps
中的变量替换变量吗?
目前不支持解析嵌套变量。
另一种解决方案是以下设置:
- 每个环境
Key Vault
- 每个环境
Stage
- 每个
Key Vault
中的键名始终相同
- Link每个金库变成一个可变组
- Link 将每个变量分组到您的管道中并分配一个
Scope
- 在
Stage
的每个任务中访问 Variable group
中声明的变量
使用此配置,您可以在任务中重复使用相同的密钥,并且实际值由您定义的每个 Stage
的变量组范围解析。
我已经通过将范围分配给变量来解决这个问题。
variable value scope
key $(dev-key) dev
key $(stg-key) stg
key $(prd-key) prd
我有Azure key vault
,其中我写了一组键
dev-key
stg-key
prd-key
现在我已经在 azure DevOps pipeline
中下载了密钥 dev-key
。我想将下载的变量映射到名为 'key'
的 'constant' 变量,因为这个变量正在部署 yaml 文件中使用(我在令牌替换步骤中替换了这个变量)
目前我正在将此变量映射到管道变量中,例如
tenant: dev
key: $($(tenant)-key)
但是在部署 yaml 文件中设置的值是 $(dev-key)
。
我们可以用 Azure DevOps
中的变量替换变量吗?
目前不支持解析嵌套变量。
另一种解决方案是以下设置:
- 每个环境
Key Vault
- 每个环境
Stage
- 每个
Key Vault
中的键名始终相同
- Link每个金库变成一个可变组
- Link 将每个变量分组到您的管道中并分配一个
Scope
- 在
Stage
的每个任务中访问Variable group
中声明的变量
使用此配置,您可以在任务中重复使用相同的密钥,并且实际值由您定义的每个 Stage
的变量组范围解析。
我已经通过将范围分配给变量来解决这个问题。
variable value scope
key $(dev-key) dev
key $(stg-key) stg
key $(prd-key) prd