我有 terraform 脚本,它创建一个 azure devops 项目、一个构建定义和 github 的服务端点。
resource "azuredevops_serviceendpoint_github" "github_serviceendpoint" {
project_id = azuredevops_project.project.id
service_endpoint_name = "GitHub Service Connection"
github_service_endpoint_pat = var.GITHUB_TOKEN
}
resource "azuredevops_build_definition" "nightly_build" {
project_id = azuredevops_project.project.id
agent_pool_name = "Hosted Ubuntu 1604"
name = "Nightly Build"
path = "\\"
repository {
repo_type = "GitHub"
repo_name = "iojas/django_ci_cd"
branch_name = "master"
yml_path = "azure-pipelines.yml"
service_connection_id = azuredevops_serviceendpoint_github.github_serviceendpoint.id
}
}
这反映了azure devops控制台中的所有资源,但推送到master分支不会触发构建。
我在
azure-pipelines.yml
中有以下触发器设置
trigger:
- master
现在,如果我使用 azure 控制台创建相同的资源,每次推送到 master 时都会触发构建。
我不确定我在这里缺少什么。
我遇到了同样的问题,这是我解决的方法。
在“azuredevops_build_definition”资源中,您可以指定一个标志:
ci_trigger {
use_yaml = true
}
这将导致构建使用 azure-pipelines 文件进行构建配置。
此选项通常设置为 false,这会导致管道 yaml 中的触发器无法工作,因为它正在查找 .tf 文件中指定的 ci 触发器。