You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# We will create it in two steps so that we don't need to go crazy with quoting and escaping. The
42
+
# first sets up a helper function, the second populates the default values for some environment
43
+
# variables.
44
+
45
+
# Step 1: Helper function. Note that we clobber the target file and DO NOT apply variable
46
+
# substitution, this is controlled by the double-quoted "EOF".
47
+
cat <<- "EOF" > /var/lib/buildkite-agent/cfn-env
48
+
# The Buildkite agent sets a number of variables such as AWS_DEFAULT_REGION to fixed values which
49
+
# are determined at AMI-build-time. However, sometimes a user might want to override such variables
50
+
# using an env: block in their pipeline.yml. This little helper is sets the environment variables
51
+
# buildkite-agent and plugins expect, except if a user want to override them, for example to do a
52
+
# deployment to a region other than where the Buildkite agent lives.
53
+
function set_unless_present() {
54
+
local target=$1
55
+
local value=$2
56
+
57
+
if [[ -v "${target}" ]]; then
58
+
echo "^^^ +++"
59
+
echo "⚠️ ${target} already set, NOT overriding! (current value \"${!target}\" set by Buildkite step env configuration, or inherited from the buildkite-agent process environment)"
60
+
else
61
+
echo "export ${target}=\"${value}\""
62
+
declare -gx "${target}=${value}"
63
+
fi
64
+
}
65
+
66
+
function set_always() {
67
+
local target=$1
68
+
local value=$2
69
+
70
+
echo "export ${target}=\"${value}\""
71
+
declare -gx "${target}=${value}"
72
+
}
73
+
EOF
74
+
75
+
# Step 2: Populate the default variable values. This time, we append to the file, and allow
# The Buildkite agent sets a number of variables such as AWS_DEFAULT_REGION to fixed values which
46
+
# are determined at AMI-build-time. However, sometimes a user might want to override such variables
47
+
# using an env: block in their pipeline.yml. This little helper is sets the environment variables
48
+
# buildkite-agent and plugins expect, except if a user want to override them, for example to do a
49
+
# deployment to a region other than where the Buildkite agent lives.
50
+
function set_unless_present() {
51
+
local target=$1
52
+
local value=$2
53
+
54
+
if [[ -v "${target}" ]]; then
55
+
echo "^^^ +++"
56
+
echo "⚠️ ${target} already set, NOT overriding! (current value \"${!target}\" set by Buildkite step env configuration, or inherited from the buildkite-agent process environment)"
0 commit comments