Commit e9a2cd31 authored by Emeric Verschuur's avatar Emeric Verschuur

[FIX] YAML variable treatment

parent 898ebdfa
...@@ -289,10 +289,11 @@ citbx_job_list() { ...@@ -289,10 +289,11 @@ citbx_job_list() {
| gawk 'match($0, /^'"$prefix"'(.*)$/, f) {'"$outcmd"'}' | 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() { gitlab_ci_variables() {
local node=$1 local node=$1
local line local value
test -n "$node" \ test -n "$node" \
|| print_critical "Usage: gitlab_ci_variables <node path>" || print_critical "Usage: gitlab_ci_variables <node path>"
local node_type="$(gitlab_ci_query -r "$node | type")" local node_type="$(gitlab_ci_query -r "$node | type")"
...@@ -302,11 +303,19 @@ gitlab_ci_variables() { ...@@ -302,11 +303,19 @@ gitlab_ci_variables() {
;; ;;
object) object)
for k in $(gitlab_ci_query -r "$node | keys[]"); do for k in $(gitlab_ci_query -r "$node | keys[]"); do
if [ "$(gitlab_ci_query -r "${node}.$k | type")" != "string" ]; then if ! [[ "$(gitlab_ci_query -r "${node}.$k | type")" =~ ^(string|number)$ ]]; then
print_critical "Invalid $node variable: $k" print_critical "Invalid $node variable (type=$(gitlab_ci_query -r "${node}.$k | type"): $k)"
fi fi
eval "export $k=$(gitlab_ci_query "${node}.$k")" value=$(
CITBX_DOCKER_RUN_ARGS+=(-e "$k") 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 done
;; ;;
*) *)
...@@ -686,6 +695,9 @@ case "$CITBX_JOB_EXECUTOR" in ...@@ -686,6 +695,9 @@ case "$CITBX_JOB_EXECUTOR" in
for e in ${CITBX_ENV_EXPORT_LIST[@]}; do for e in ${CITBX_ENV_EXPORT_LIST[@]}; do
export $e export $e
done done
for e in "${!CITBX_SHELL_ENV[@]}"; do
eval "export $e=${CITBX_SHELL_ENV[$e]}"
done
eval "$CITBX_JOB_SHELL -c $CITBX_JOB_SCRIPT" 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