Skip to content
Snippets Groups Projects
Commit 374ea335 authored by Lukas Werner's avatar Lukas Werner
Browse files

Added some colored status messages

parent e331d7c8
No related merge requests found
#!/bin/bash -l #!/bin/bash -l
set -euf -o pipefail set -euf -o pipefail
shopt -s inherit_errexit shopt -s inherit_errexit
TXT_RED="\e[31m"
TXT_BLUE="\e[94m"
TXT_GREEN="\e[32m"
TXT_CLEAR="\e[0m"
TXT_BOLD="\e[1m"
hash awk hash awk
hash chown hash chown
hash diff hash diff
...@@ -13,7 +19,7 @@ hash ssh-keygen ...@@ -13,7 +19,7 @@ hash ssh-keygen
function error { function error {
: "${RV:=${2:-$BUILD_FAILURE_EXIT_CODE}}" : "${RV:=${2:-$BUILD_FAILURE_EXIT_CODE}}"
echo "$1" >&2 echo -e "${TXT_RED}${TXT_BOLD}$1${TXT_CLEAR}" >&2
return "$RV" return "$RV"
} }
...@@ -44,7 +50,7 @@ exit 1 ...@@ -44,7 +50,7 @@ exit 1
AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK") AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK")
: "${AUTH_USER_WORK:?"Could not determine $AUTH_USER's \$WORK directory."}" : "${AUTH_USER_WORK:?"${TXT_RED}${TXT_BOLD}Could not determine $AUTH_USER's \$WORK directory.${TXT_CLEAR}"}"
BASE_DIR=$AUTH_USER_WORK/gitlab-runner/builds/${CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID:?}/${CUSTOM_ENV_CI_PROJECT_NAMESPACE:?}/${CUSTOM_ENV_CI_PROJECT_NAME:?} BASE_DIR=$AUTH_USER_WORK/gitlab-runner/builds/${CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID:?}/${CUSTOM_ENV_CI_PROJECT_NAMESPACE:?}/${CUSTOM_ENV_CI_PROJECT_NAME:?}
......
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
set -euf -o pipefail set -euf -o pipefail
shopt -s inherit_errexit shopt -s inherit_errexit
: "${CUSTOM_ENV_AUTH_USER:?"AUTH_USER CI/CD variable has not been set."}" TXT_RED="\e[31m"
: "${CUSTOM_ENV_AUTH_KEY:?"AUTH_KEY secret CI/CD variable has not been set."}" TXT_BLUE="\e[94m"
TXT_GREEN="\e[32m"
TXT_CLEAR="\e[0m"
TXT_BOLD="\e[1m"
: "${CUSTOM_ENV_AUTH_USER:?"${TXT_RED}${TXT_BOLD}AUTH_USER CI/CD variable has not been set.${TXT_CLEAR}"}"
: "${CUSTOM_ENV_AUTH_KEY:?"${TXT_RED}${TXT_BOLD}AUTH_KEY secret CI/CD variable has not been set.${TXT_CLEAR}"}"
AUTH_USER=$CUSTOM_ENV_AUTH_USER AUTH_USER=$CUSTOM_ENV_AUTH_USER
AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK") AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK")
: "${AUTH_USER_WORK:?"Could not determine $AUTH_USER's \$WORK directory."}" : "${AUTH_USER_WORK:?"${TXT_RED}${TXT_BOLD}Could not determine $AUTH_USER's \$WORK directory.${TXT_CLEAR}"}"
cat << EOS cat << EOS
{ {
......
...@@ -4,6 +4,12 @@ shopt -s inherit_errexit ...@@ -4,6 +4,12 @@ shopt -s inherit_errexit
MAX_CI_JOB_RUNTIME=120 MAX_CI_JOB_RUNTIME=120
TXT_RED="\e[31m"
TXT_BLUE="\e[94m"
TXT_GREEN="\e[32m"
TXT_CLEAR="\e[0m"
TXT_BOLD="\e[1m"
hash awk hash awk
hash chown hash chown
hash diff hash diff
...@@ -18,7 +24,7 @@ hash sinfo ...@@ -18,7 +24,7 @@ hash sinfo
function error { function error {
: "${RV:=${2:-$BUILD_FAILURE_EXIT_CODE}}" : "${RV:=${2:-$BUILD_FAILURE_EXIT_CODE}}"
echo "$1" >&2 echo -e "${TXT_RED}${TXT_BOLD}$1${TXT_CLEAR}" >&2
return "$RV" return "$RV"
} }
...@@ -110,6 +116,8 @@ if [[ ("$2" == "step_script" || "$2" == "build_script") && "${CUSTOM_ENV_NO_SLUR ...@@ -110,6 +116,8 @@ if [[ ("$2" == "step_script" || "$2" == "build_script") && "${CUSTOM_ENV_NO_SLUR
\"$AUTH_USER_SHELL\" --login \"$BASE_DIR.tmp/$CUSTOM_ENV_CI_JOB_ID.sh\"" >> "$TMPDIR"/salloc.sh \"$AUTH_USER_SHELL\" --login \"$BASE_DIR.tmp/$CUSTOM_ENV_CI_JOB_ID.sh\"" >> "$TMPDIR"/salloc.sh
chmod +x "$TMPDIR"/salloc.sh chmod +x "$TMPDIR"/salloc.sh
echo -e "${TXT_GREEN}${TXT_BOLD}Submitting job to node $SLURM_NODELIST...${TXT_CLEAR}"
exec runuser --login "$AUTH_USER" --command "$TMPDIR"/salloc.sh exec runuser --login "$AUTH_USER" --command "$TMPDIR"/salloc.sh
#exec runuser --login "$AUTH_USER" --command "salloc --quiet --chdir \"$BASE_DIR\" ${SALLOC_OPTIONS[@]} \ #exec runuser --login "$AUTH_USER" --command "salloc --quiet --chdir \"$BASE_DIR\" ${SALLOC_OPTIONS[@]} \
......
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