-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.bash
executable file
·44 lines (42 loc) · 1.58 KB
/
config.bash
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
#!/usr/bin/env bash
# DO NOT RETURN ANYTHING BUT THE JSON BELOW UNLESS IT'S TO STDERR
echo "=======================" >&2
echo "] Configuring..." >&2
# get current script path
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
. "${SCRIPT_DIR}/shared.bash"
CUSTOM_ENV_ANKA_CUSTOM_EXECUTOR_VERSION="$(cat ${SCRIPT_DIR}/VERSION)"
set -eo pipefail
# ensure we only ever retry the specific step, not the whole job (and all steps)
cleanup_config () {
[[ $? -eq $RETRY_STEP_EXIT_CODE ]] && exit $RETRY_STEP_EXIT_CODE || exit $BUILD_FAILURE_EXIT_CODE
}
trap cleanup_config ERR
#############################
# job_env is where we can put ENVs that will be available to all steps in the executor.
CUSTOM_ENVS="$(env | grep ^CUSTOM_ENV_ANKA)"
CUSTOM_ENVS_COUNT="$(echo "${CUSTOM_ENVS}" | wc -l | xargs)"
CONFIG=$(cat <<EOS
{
"builds_dir": "${HOME}/builds/${CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID}/${CUSTOM_ENV_CI_PROJECT_PATH_SLUG}",
"cache_dir": "${HOME}/caches/${CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID}/${CUSTOM_ENV_CI_PROJECT_PATH_SLUG}",
"builds_dir_is_shared": true,
"runner_hostname": "$(hostname)",
"runner_arch": "$(arch)",
"driver": {
"name": "Anka Gitlab Custom Executor",
"version": "${CUSTOM_ENV_ANKA_CUSTOM_EXECUTOR_VERSION}"
},
"job_env": {
$(for FOUND_ENV in ${CUSTOM_ENVS}; do
[[ ${CUSTOM_ENVS_COUNT} -gt 1 ]] && COMMA="," || COMMA=
FOUND_ENV="\"${FOUND_ENV/=/\": \"}\"${COMMA}"
echo "${FOUND_ENV}"
((CUSTOM_ENVS_COUNT--))
done)
}
}
EOS
)
set +x;echo "${CONFIG}";
if ${CUSTOM_ENV_ANKA_ENABLE_JOB_DEBUG_LOGGING:-false}; then set -x; fi