Skip to content

Commit 78d91fb

Browse files
authored
Merge pull request #5 from joinhandshake/apr/buildkite-agent
Backport support for mount-buildkite-agent
2 parents 41ce244 + 5e0d970 commit 78d91fb

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

commands/run.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,28 @@ if [[ "$(plugin_read_config USE_ALIASES "false")" == "true" ]] ; then
131131
run_params+=(--use-aliases)
132132
fi
133133

134+
# Optionally handle the mount-buildkite-agent option
135+
if [[ "$(plugin_read_config MOUNT_BUILDKITE_AGENT "false")" == "true" ]]; then
136+
if [[ -z "${BUILDKITE_AGENT_BINARY_PATH:-}" ]] ; then
137+
if ! command -v buildkite-agent >/dev/null 2>&1 ; then
138+
echo -n "+++ 🚨 Failed to find buildkite-agent in PATH to mount into container, "
139+
echo "you can disable this behaviour with 'mount-buildkite-agent:false'"
140+
else
141+
BUILDKITE_AGENT_BINARY_PATH=$(command -v buildkite-agent)
142+
fi
143+
fi
144+
fi
145+
146+
# Mount buildkite-agent if we have a path for it
147+
if [[ -n "${BUILDKITE_AGENT_BINARY_PATH:-}" ]] ; then
148+
run_params+=(
149+
"--env" "BUILDKITE_JOB_ID"
150+
"--env" "BUILDKITE_BUILD_ID"
151+
"--env" "BUILDKITE_AGENT_ACCESS_TOKEN"
152+
"--volume" "$BUILDKITE_AGENT_BINARY_PATH:/usr/bin/buildkite-agent"
153+
)
154+
fi
155+
134156
run_params+=("$run_service")
135157

136158
if [[ "${BUILDKITE_PLUGIN_DOCKER_COMPOSE_REQUIRE_PREBUILD:-}" =~ ^(true|on|1)$ ]] && [[ ! -f "$override_file" ]] ; then

plugin.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ configuration:
6666
type: boolean
6767
workdir:
6868
type: string
69+
mount-buildkite-agent:
70+
type: boolean
6971
oneOf:
7072
- required:
7173
- run
@@ -92,3 +94,4 @@ configuration:
9294
tty: [ run ]
9395
workdir: [ run ]
9496
user: [ run ]
97+
mount-buildkite-agent: [ run ]

0 commit comments

Comments
 (0)