gpt4 book ai didi

Azure Devops Pipelines - 添加多个/批量变量

转载 作者:行者123 更新时间:2023-12-03 06:35:24 25 4
gpt4 key购买 nike

我使用下面的 azure-pipeline.yml 文件来构建 docker 镜像,推送到 Azure docker 注册表并重新启动 Azure docker 应用服务程序。

此 yaml 文件使用 azure 管道中设置的变量,附有屏幕截图。

我的问题是,我需要每周为不同的项目创建 2-3 个管道,我需要为每个项目手动添加每个变量并从我的配置中复制粘贴。有没有办法可以在创建管道时导入 .env 文件或一次性添加多个变量。

客观上我需要减少单个变量复制粘贴时间并避免可能发生的错误

enter image description here

最佳答案

1.您可以使用variable group重用变量。

trigger: 
- none

pool:
vmImage: ubuntu-latest

variables:
- group: forTest

steps:
- script: |
echo $(test1)
echo $(test2)
displayName: 'Run a multi-line script'

enter image description here

2.您可以使用variable template .

trigger: 
- none

pool:
vmImage: ubuntu-latest

variables:
- template: vars.yml

steps:

- script: |
echo $(test1)
echo $(test2)
displayName: 'Run a multi-line script'

enter image description here

关于Azure Devops Pipelines - 添加多个/批量变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74920184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com