-
Notifications
You must be signed in to change notification settings - Fork 299
Expand file tree
/
Copy pathenvironment
More file actions
executable file
·72 lines (58 loc) · 2.45 KB
/
Copy pathenvironment
File metadata and controls
executable file
·72 lines (58 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -eu -o pipefail
echo "~~~ :earth_asia: Setting up environment variables"
# shellcheck source=/dev/null
source /c/buildkite-agent/cfn-env
# a clean docker config for each job, for improved isolation
BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY=$(mktemp -d)
export BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY
export DOCKER_CONFIG="$BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY"
if [ "${BUILDKITE_DOCKER_EXPERIMENTAL:-false}" = "true" ]; then
#shellcheck disable=SC2094 # Redirections to the same command are processed in order
cat <<<"$(jq '.experimental="enabled"' "${DOCKER_CONFIG}/config.json")" >"${DOCKER_CONFIG}/config.json"
fi
echo "~~~ :llama: Setting up elastic stack environment ($BUILDKITE_STACK_VERSION)"
echo "Configuring built-in plugins"
[[ ! ${SECRETS_PLUGIN_ENABLED:-true} =~ (on|1|true) ]] && PLUGINS_ENABLED=${PLUGINS_ENABLED/secrets/}
[[ ! ${DOCKER_LOGIN_PLUGIN_ENABLED:-true} =~ (on|1|true) ]] && PLUGINS_ENABLED=${PLUGINS_ENABLED/docker-login/}
[[ ! ${ECR_PLUGIN_ENABLED:-true} =~ (on|1|true) ]] && PLUGINS_ENABLED=${PLUGINS_ENABLED/ecr/}
SECRETS_PLUGIN_ENABLED=0
DOCKER_LOGIN_PLUGIN_ENABLED=0
ECR_PLUGIN_ENABLED=0
for plugin in $PLUGINS_ENABLED; do
case "$plugin" in
secrets)
export SECRETS_PLUGIN_ENABLED=1
echo "Secrets plugin enabled"
;;
docker-login)
export DOCKER_LOGIN_PLUGIN_ENABLED=1
echo "Docker-login plugin enabled"
;;
ecr)
export ECR_PLUGIN_ENABLED=1
echo "ECR plugin enabled"
;;
esac
done
if [[ -n "${BUILDKITE_SECRETS_BUCKET:-}" && "${SECRETS_PLUGIN_ENABLED:-}" == "1" ]]; then
export BUILDKITE_PLUGIN_S3_SECRETS_BUCKET="$BUILDKITE_SECRETS_BUCKET"
export BUILDKITE_PLUGIN_S3_SECRETS_REGION="$BUILDKITE_SECRETS_BUCKET_REGION"
# shellcheck source=/dev/null
source /usr/local/buildkite-aws-stack/plugins/secrets/hooks/environment
fi
if [[ "${BUILDKITE_ECR_POLICY:-}" != "none" && "${ECR_PLUGIN_ENABLED:-}" == "1" ]]; then
export BUILDKITE_PLUGIN_ECR_LOGIN=1
export BUILDKITE_PLUGIN_ECR_RETRIES=3
export BUILDKITE_PLUGIN_ECR_CREDENTIAL_HELPER=true
# map AWS_ECR_LOGIN_REGISTRY_IDS into the plugin list format
if [[ -n "${AWS_ECR_LOGIN_REGISTRY_IDS:-}" ]]; then
export BUILDKITE_PLUGIN_ECR_ACCOUNT_IDS_0="${AWS_ECR_LOGIN_REGISTRY_IDS}"
fi
# map AWS_ECR_LOGIN into the plugin format
if [[ -n "${AWS_ECR_LOGIN:-}" ]]; then
export BUILDKITE_PLUGIN_ECR_LOGIN="${AWS_ECR_LOGIN}"
fi
# shellcheck source=/dev/null
source /usr/local/buildkite-aws-stack/plugins/ecr/hooks/environment
fi