Commit e9a2cd31 authored by Emeric Verschuur's avatar Emeric Verschuur

[FIX] YAML variable treatment

parent 898ebdfa
......@@ -289,10 +289,11 @@ citbx_job_list() {
| gawk 'match($0, /^'"$prefix"'(.*)$/, f) {'"$outcmd"'}'
}
# put YAML variables indo CITBX_YAML_SCRIPT_ELTS
declare -A CITBX_SHELL_ENV
# fetch YAML variables
gitlab_ci_variables() {
local node=$1
local line
local value
test -n "$node" \
|| print_critical "Usage: gitlab_ci_variables <node path>"
local node_type="$(gitlab_ci_query -r "$node | type")"
......@@ -302,11 +303,19 @@ gitlab_ci_variables() {
;;
object)
for k in $(gitlab_ci_query -r "$node | keys[]"); do
if [ "$(gitlab_ci_query -r "${node}.$k | type")" != "string" ]; then
print_critical "Invalid $node variable: $k"
if ! [[ "$(gitlab_ci_query -r "${node}.$k | type")" =~ ^(string|number)$ ]]; then
print_critical "Invalid $node variable (type=$(gitlab_ci_query -r "${node}.$k | type"): $k)"
fi
eval "export $k=$(gitlab_ci_query "${node}.$k")"
CITBX_DOCKER_RUN_ARGS+=(-e "$k")
value=$(
eval "$k=$(gitlab_ci_query "${node}.$k")"
declare | grep "^$k=" | sed -E 's/^[^=]+=//g'
)
case "$k" in
CITBX_*|GIT_*|CI_*)
eval "export $k=$value"
esac
CITBX_SHELL_ENV[$k]=$value
CITBX_DOCKER_RUN_ARGS+=(-e "$k=$(eval echo "$value")")
done
;;
*)
......@@ -686,6 +695,9 @@ case "$CITBX_JOB_EXECUTOR" in
for e in ${CITBX_ENV_EXPORT_LIST[@]}; do
export $e
done
for e in "${!CITBX_SHELL_ENV[@]}"; do
eval "export $e=${CITBX_SHELL_ENV[$e]}"
done
eval "$CITBX_JOB_SHELL -c $CITBX_JOB_SCRIPT"
)
;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment