Skip to content

Commit d3dc683

Browse files
committed
Don't overwrite BUILDKITE_METAHOOK_HOOKS_PATH
If we have multiple `metahook` instances, let's not generate multiple temporary directories; instead just create one (and only dump the environment variables once). This fixed an issue with multiple `metahook` instances in a pipeline of mine.
1 parent 5fb4afe commit d3dc683

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hooks/environment

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
BUILDKITE_METAHOOK_HOOKS_PATH="$(mktemp -d)"
5-
export BUILDKITE_METAHOOK_HOOKS_PATH
6-
env | sort | grep "BUILDKITE_PLUGIN_METAHOOK" | uniq >"${BUILDKITE_METAHOOK_HOOKS_PATH}/vars"
4+
# If users add multiple `metahook` instances, we'll just store our `vars` in the same directory.
5+
if [[ ! -v "BUILDKITE_METAHOOK_HOOKS_PATH" ]]; then
6+
export BUILDKITE_METAHOOK_HOOKS_PATH="$(mktemp -d)"
7+
env | sort | grep "BUILDKITE_PLUGIN_METAHOOK" | uniq >"${BUILDKITE_METAHOOK_HOOKS_PATH}/vars"
8+
fi
79

810
if grep -E 'BUILDKITE_PLUGIN_METAHOOK_.+(\.BAT|\.CMD)=' "${BUILDKITE_METAHOOK_HOOKS_PATH}/vars"; then
911
echo "Sorry, we had to remove Windows Batch file support in 0.4.0."

0 commit comments

Comments
 (0)