Skip to content

Commit 11a8720

Browse files
committed
Refactor CI trigger configuration
1 parent 12d788d commit 11a8720

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

modules/azuredevops/GitHub-Build-Definition/github_build_definition.tf

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,33 @@ resource "azuredevops_build_definition" "devops_build_definition" {
1616
path = var.pipeline_path
1717
queue_status = var.status
1818

19-
ci_trigger {
20-
use_yaml = true
19+
dynamic "ci_trigger" {
20+
for_each = var.ci_trigger_use_yaml ? [1] : []
21+
content {
22+
use_yaml = true
23+
}
24+
}
25+
26+
dynamic "ci_trigger" {
27+
for_each = var.ci_trigger_use_yaml == false ? [1] : []
28+
content {
29+
dynamic "override" {
30+
for_each = var.ci_trigger_overrides
31+
content {
32+
batch = override.value.batch
33+
max_concurrent_builds_per_branch = override.value.max_concurrent_builds_per_branch
34+
polling_interval = override.value.polling_interval
35+
branch_filter {
36+
exclude = override.value.branch_filter_exclude_list
37+
include = override.value.branch_filter_include_list
38+
}
39+
path_filter {
40+
exclude = override.value.path_filter_exclude_list
41+
include = override.value.path_filter_include_list
42+
}
43+
}
44+
}
45+
}
2146
}
2247

2348
repository {

modules/azuredevops/GitHub-Build-Definition/variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,23 @@ variable "status" {
6767
description = "The queue status of the build definition. Valid values: enabled or paused or disabled"
6868
type = string
6969
}
70+
71+
variable "ci_trigger_use_yaml" {
72+
default = true
73+
description = "Use YAML for CI trigger"
74+
type = bool
75+
}
76+
77+
variable "ci_trigger_overrides" {
78+
default = []
79+
description = "Overrides for the CI trigger. Only used when ci_trigger_use_yaml is false."
80+
type = list(object({
81+
batch = bool
82+
max_concurrent_builds_per_branch = number
83+
polling_interval = number
84+
branch_filter_exclude_list = list(string)
85+
branch_filter_include_list = list(string)
86+
path_filter_exclude_list = list(string)
87+
path_filter_include_list = list(string)
88+
}))
89+
}

0 commit comments

Comments
 (0)