bash - 将 Azure DevOps Group Vars 作为 Enviroment Vars 访问
问题描述
是否可以在 bash 步骤中将 azure DevOps 变量组中的所有变量作为环境变量访问?
充其量我想要一种方法来访问所有组变量作为python脚本中的环境变量。
因此,yaml
我想到了以下类似的内容,但对其他想法持开放态度。没错,我将组中的每个 var 添加为 env 参数,但是yaml
如果我想在组中添加新 var,我总是要更新 azure DevOps。就是感觉不太对啊。。。。
pool:
vmImage: ubuntu-latest
variables:
- group: myGroup
stages:
- stage: test
jobs:
- job: test
displayName: Test
steps:
- bash: |
echo $path.myGroup
group:
- myGroup
解决方案
这是不可能的。但是,您可以尝试使用azure CLI来获取组内非机密变量的名称和值。它不会为您返回秘密变量的值,但是对于它们,您仍然必须显式地映射它们。
如果你这样做:
pool:
vmImage: ubuntu-latest
stages:
- stage: test
jobs:
- job: test
displayName: Test
variables:
- group: myGroup
steps:
- bash: |
echo 'You have all non secret variables ampped to env variables`
echo `You can use Azure Cli to get all names of the mapped variables from variables group`
您将获得所有非秘密变量的映射。
你也可以使用
variables:
- group: myGroup
在顶层实现相同,但随后您将在所有工作中映射它。
推荐阅读
- node.js - 解析时可以在 grapqhl 中返回字符串或对象吗?
- node.js - 部署到 Elasticbeanstalk Node.js 后无法将图像上传到 S3 存储桶
- reactjs - react/redux app - 从 redux slice 获取操作以响应组件时出现问题
- pandas - 绘制时间线图
- vb.net - 如何在两个日期之间填充列表视图 vb.net
- javascript - Firefox 安装插件提示
- python - 生成 IPv6 后缀
- amazon-web-services - 了解 Kubernetes 中的实际子网和虚拟子网
- spring - 使用 Builder 和绑定表达式创建的 JavaFX 自定义控件
- r - 我在 AS-Reml R 中的“错误:因子级别 [4] 重复”是什么意思?