Commit 2df9c541 authored by Lukas Werner's avatar Lukas Werner
Browse files

Better and more consistent error messages

parent 77964f9e
......@@ -25,8 +25,8 @@ function error {
## User authentication
: "${CUSTOM_ENV_AUTH_USER:?"AUTH_USER CI/CD variable has not been set."}"
: "${CUSTOM_ENV_AUTH_KEY:?"AUTH_KEY CI/CD variable has not been set."}"
[ -z "$CUSTOM_ENV_AUTH_USER" ] && error "AUTH_USER CI/CD variable has not been set."
[ -z "$CUSTOM_ENV_AUTH_KEY" ] && error "AUTH_KEY secret CI/CD variable has not been set."
AUTH_USER=$CUSTOM_ENV_AUTH_USER
......@@ -50,7 +50,7 @@ exit 1
AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK")
: "${AUTH_USER_WORK:?"${TXT_RED}${TXT_BOLD}Could not determine $AUTH_USER's \$WORK directory.${TXT_CLEAR}"}"
[ -z "$AUTH_USER_WORK" ] && error "Could not determine $AUTH_USER's \$WORK directory."
BASE_DIR=$AUTH_USER_WORK/gitlab-runner/builds/${CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID:?}/${CUSTOM_ENV_CI_PROJECT_NAMESPACE:?}/${CUSTOM_ENV_CI_PROJECT_NAME:?}
......
......@@ -8,14 +8,14 @@ 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}"}"
[ -z "$CUSTOM_ENV_AUTH_USER" ] && error "AUTH_USER CI/CD variable has not been set."
[ -z "$CUSTOM_ENV_AUTH_KEY" ] && error "AUTH_KEY secret CI/CD variable has not been set."
AUTH_USER=$CUSTOM_ENV_AUTH_USER
AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK")
: "${AUTH_USER_WORK:?"${TXT_RED}${TXT_BOLD}Could not determine $AUTH_USER's \$WORK directory.${TXT_CLEAR}"}"
[ -z "$AUTH_USER_WORK" ] && error "Could not determine $AUTH_USER's \$WORK directory."
cat << EOS
{
......
......@@ -30,8 +30,8 @@ function error {
## User authentication
: "${CUSTOM_ENV_AUTH_USER:?"AUTH_USER CI/CD variable has not been set."}"
: "${CUSTOM_ENV_AUTH_KEY:?"AUTH_KEY CI/CD variable has not been set."}"
[ -z "$CUSTOM_ENV_AUTH_USER" ] && error "AUTH_USER CI/CD variable has not been set."
[ -z "$CUSTOM_ENV_AUTH_KEY" ] && error "AUTH_KEY secret CI/CD variable has not been set."
AUTH_USER=$CUSTOM_ENV_AUTH_USER
......@@ -57,7 +57,7 @@ AUTH_USER_HOME=$(getent passwd "$AUTH_USER" | awk -F ":" '{print $6}')
AUTH_USER_SHELL=$(getent passwd "$AUTH_USER" | awk -F ":" '{print $7}')
AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK")
: "${AUTH_USER_WORK:?"Could not determine $AUTH_USER's \$WORK directory."}"
[ -z "$AUTH_USER_WORK" ] && error "Could not determine $AUTH_USER's \$WORK directory."
chown -R "$AUTH_USER" "$TMPDIR"
......@@ -79,7 +79,7 @@ if [[ ("$2" == "step_script" || "$2" == "build_script") && "${CUSTOM_ENV_NO_SLUR
: "${SLURM_NODELIST:="phinally"}" # default node: phinally
if [ ! $(sinfo -n "$SLURM_NODELIST" -h -O NodeList) ]; then
echo "${TXT_RED}${TXT_BOLD}Unknown node \"$SLURM_NODELIST\" specified. Available nodes: ${TXT_CLEAR}" >&2
echo -e "${TXT_RED}${TXT_BOLD}Unknown node \"$SLURM_NODELIST\" specified. Available nodes: ${TXT_CLEAR}" >&2
echo "$(sinfo -N -o '%N %c %m')" >&2
error "Exiting..."
fi
......
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