【发布时间】:2019-03-26 16:26:17
【问题描述】:
我目前正在为 Azure DevOps 创建一个管道,以验证 Terraform 配置并将其应用于不同的订阅。
我的 terraform 配置使用模块,这些模块“托管”在与 terraform 配置相同的 Azure DevOps 项目中的其他存储库中。
可悲的是,当我尝试执行 terraform init 来获取这些模块时,管道任务“挂起”在那里等待凭据输入。
按照Pipeline Documentation on Running Git Commands in a script 中的建议,我尝试使用persistCredentials:true 属性添加checkout 步骤。
从我在任务日志中看到的(见下文),凭据信息是专门添加到当前存储库中的,不能用于其他存储库。
添加persistCredentials:true时执行的命令
2018-10-22T14:06:54.4347764Z ##[command]git config http.https://my-org@dev.azure.com/my-org/my-project/_git/my-repo.extraheader "AUTHORIZATION: bearer ***"
terraform init 任务的输出
2018-10-22T14:09:24.1711473Z terraform init -input=false
2018-10-22T14:09:24.2761016Z Initializing modules...
2018-10-22T14:09:24.2783199Z - module.my-module
2018-10-22T14:09:24.2786455Z Getting source "git::https://my-org@dev.azure.com/my-org/my-project/_git/my-module-repo?ref=1.0.2"
如何设置 git 凭据以用于其他存储库?
【问题讨论】:
标签: azure-devops terraform azure-pipelines azure-repos