我在代码库中使用 Azure devops yml 管道。
我在管道(管道 > 库 > 变量组 > 称为“MY_VG”)创建了变量组。在我的管道(yml)文件中,我想将此变量组 MY_VG 作为参数发送到模板 my_template.yml。
但是当我在“变量”下使用它时,这个参数 MY_VG 并没有被扩展(尽管在打印时它给了我值)
如何访问下面所示的模板组中的 MY_VG 的值:${{parameters.variable_group}}?
(我正在调用模板文件 my_template_iterator.yml,它会迭代环境并调用 my_template.yml) azure-pipelines.yml
resources:
repositories:
- repository: templates
type: git
name: MY_PROJECT/GIT_REPO_FOR_TEMPLATE
stages:
- stage: "CheckOut"
displayName: Checkout
jobs:
- job: Checkout
displayName: Checkout Application
pool:
name: $(my_pool_name)
workspace:
clean: all
steps:
- checkout: self
- template: folder_name/my_template_iterator.yml@templates
parameters:
agent_pool_name: $(my_pool)
db_resource_path: $(System.DefaultWorkingDirectory)/src/main/resources/db
envs:
- env:
env_name: 'dev'
variable_group: MY_VG
pipeline_environment_name: DEV_ENV
is_master: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
Run Code Online (Sandbox Code Playgroud)
## 迭代器:my_template_iterator.yml …
您能否建议让 .env 文件可用于我的 azure devops 管道的最佳方法。(注意我们忽略了要推送到 Git 存储库的 .env 文件)
我的 Node.js 实用程序代码库位于 azure-devops Git 中。
我有一个 azure 构建管道(YML 版本),它是一个 CI 管道(只进行编译和测试)。
单元测试使用需要 API 秘密令牌才能运行的 API 调用。
这些令牌存储在 .env 文件中(我使用了 Node.js 的 dotenv 包)但我们不会将 .env 文件推送到 Git。
那么我应该如何使 .env 文件可用于我的 CI 管道。