Skip to content

Commit c318510

Browse files
committed
Add multiline support for runner's build scripts
1 parent bc06844 commit c318510

File tree

6 files changed

+173
-125
lines changed

6 files changed

+173
-125
lines changed

README.md

+154-117
Large diffs are not rendered by default.

examples/runner-default/_docs/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ This examples shows:
88
- Registration via GitLab token.
99
- Auto scaling using `docker+machine` executor.
1010
- Addtional security groups that are allowed access to the runner agent
11+
- A multiline pre build script
12+
- A single line post build script
1113

1214
![runners-default](https://github.com/npalm/assets/raw/master/images/terraform-aws-gitlab-runner/runner-default.png)
1315

examples/runner-default/main.tf

+9
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ module "runner" {
9292
timezone = var.timezone
9393
}
9494
]
95+
96+
runners_pre_build_script = <<EOT
97+
'''
98+
echo 'multiline 1'
99+
echo 'multiline 2'
100+
'''
101+
EOT
102+
103+
runners_post_build_script = "\"echo 'single line'\""
95104
}
96105

97106
resource "null_resource" "cancel_spot_requests" {

main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ resource "null_resource" "remove_runner" {
3838
}
3939

4040
locals {
41-
enable_asg_recreation = var.enable_forced_updates != null ? ! var.enable_forced_updates : var.enable_asg_recreation
41+
enable_asg_recreation = var.enable_forced_updates != null ? !var.enable_forced_updates : var.enable_asg_recreation
4242

4343
template_user_data = templatefile("${path.module}/template/user-data.tpl",
4444
{
@@ -123,7 +123,7 @@ locals {
123123
runners_root_size = var.runners_root_size
124124
runners_iam_instance_profile_name = var.runners_iam_instance_profile_name
125125
runners_use_private_address_only = var.runners_use_private_address
126-
runners_use_private_address = ! var.runners_use_private_address
126+
runners_use_private_address = !var.runners_use_private_address
127127
runners_request_spot_instance = var.runners_request_spot_instance
128128
runners_environment_vars = jsonencode(var.runners_environment_vars)
129129
runners_pre_build_script = var.runners_pre_build_script

template/runner-config.tpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ check_interval = 0
77
token = "${runners_token}"
88
executor = "${runners_executor}"
99
environment = ${runners_environment_vars}
10-
pre_build_script = "${runners_pre_build_script}"
11-
post_build_script = "${runners_post_build_script}"
12-
pre_clone_script = "${runners_pre_clone_script}"
10+
pre_build_script = ${runners_pre_build_script}
11+
post_build_script = ${runners_post_build_script}
12+
pre_clone_script = ${runners_pre_clone_script}
1313
request_concurrency = ${runners_request_concurrency}
1414
output_limit = ${runners_output_limit}
1515
limit = ${runners_limit}

variables.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,19 @@ variable "runners_environment_vars" {
257257
variable "runners_pre_build_script" {
258258
description = "Script to execute in the pipeline just before the build, will be used in the runner config.toml"
259259
type = string
260-
default = ""
260+
default = "\"\""
261261
}
262262

263263
variable "runners_post_build_script" {
264264
description = "Commands to be executed on the Runner just after executing the build, but before executing after_script. "
265265
type = string
266-
default = ""
266+
default = "\"\""
267267
}
268268

269269
variable "runners_pre_clone_script" {
270270
description = "Commands to be executed on the Runner before cloning the Git repository. this can be used to adjust the Git client configuration first, for example. "
271271
type = string
272-
default = ""
272+
default = "\"\""
273273
}
274274

275275
variable "runners_request_concurrency" {

0 commit comments

Comments
 (0)