Commit 62996ae2 authored by Emeric Verschuur's avatar Emeric Verschuur

[job-advanced] Update job-advanced example job:

* Remove citbx_run_ext_job call
* Add test to check YAML variable scope
parent bce7225c
......@@ -2,7 +2,7 @@
image: ubuntu:16.04
variables:
GLOBALJOBVAR: "global variable"
GLOBAL_TEST_VAR: "scope: global"
after_script:
- echo "job ${CI_JOB_NAME} end"
......@@ -34,10 +34,8 @@ job-advanced:
tags:
- docker
variables:
JOBADVAR: "${CI_JOB_NAME} JOBADVAR value"
JOB_TEST_VAR: "${CI_JOB_NAME} - ${GLOBAL_TEST_VAR}"
script:
- echo ${GLOBALJOBVAR}
- echo ${JOBADVAR}
- ci-scripts/run-job-script.sh
job-test-services-mysql:
......
......@@ -3,10 +3,10 @@ citbx_use "example"
job_define() {
# You can: Define options:
bashopts_declare -n RUN_JOB_MINIMAL_BEFORE -l run-min-job \
-d "Run minimal job before" -s -i -t boolean
bashopts_declare -n JOB_OPTION_LOCAL -l job-opt-local \
-d "Local job option not accessible from the docker" -s -i -t string -v "my local value"
bashopts_declare -n JOB_OPTION_EXPORT -l job-opt-export \
-d "Local job option accissible from the docker" -s -i -t string -v "my exported value"
-d "Job option accessible from the docker" -s -i -t string -v "my exported value"
bashopts_declare -n JOB_OPTION_EXIT_CODE -l job-exit-code \
-d "Job exit code" -i -t number -v "0"
# Add JOB_OPTION_EXPORT to the export list
......@@ -20,20 +20,19 @@ job_setup() {
" * on the host (outside the docker container)" \
" * before start the suitable docker container"
print_note "Outside the docker:" \
"* RUN_JOB_MINIMAL_BEFORE=\"$RUN_JOB_MINIMAL_BEFORE\"" \
"* JOB_OPTION_LOCAL=\"$JOB_OPTION_LOCAL\"" \
"* JOB_OPTION_EXPORT=\"$JOB_OPTION_EXPORT\""
if [ "$RUN_JOB_MINIMAL_BEFORE" == "true" ]; then
citbx_run_ext_job job-minimal
fi
# Test variable scope
test "$JOB_TEST_VAR" == "job-advanced - scope: global"
}
job_main() {
print_info "This part is executed into the suitable docker container"
if [[ ! -v RUN_JOB_MINIMAL_BEFORE ]]; then
print_info " [ OK ] RUN_JOB_MINIMAL_BEFORE=\"$RUN_JOB_MINIMAL_BEFORE\" (is not defined as expected)"
if [[ ! -v JOB_OPTION_LOCAL ]]; then
print_info " [ OK ] JOB_OPTION_LOCAL=\"$JOB_OPTION_LOCAL\" (is not defined as expected)"
else
print_critical " [ KO ] RUN_JOB_MINIMAL_BEFORE=\"$RUN_JOB_MINIMAL_BEFORE\" (is defined)"
print_critical " [ KO ] JOB_OPTION_LOCAL=\"$JOB_OPTION_LOCAL\" (is defined)"
fi
if [[ -v JOB_OPTION_EXPORT ]]; then
......
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