Skip to content
Snippets Groups Projects
Commit e4522513 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

add helper script to

parent fcb6b504
No related branches found
No related tags found
1 merge request!62V2.0
#!/bin/bash
# ======================================================================
#
# HELPER :: GO TO A BUILD DIRECTORY
#
# Jump to a build directory to debug build errors.
#
# ----------------------------------------------------------------------
# 2024-01-19 v1.0 <axel.hahn@iml.unibe.ch> first lines
# ======================================================================
cd $( dirname $0 )/..
CI_APPROOT=$( pwd )
# ----------------------------------------------------------------------
# header
# ----------------------------------------------------------------------
cat <<HEADEREND
+----------------------------------------------------------------------
| CI SERVER * helper script
| Jump to a build directory to debug build errors
:
HEADEREND
# ----------------------------------------------------------------------
# detect workdir
# ----------------------------------------------------------------------
datadefault=$( grep "'workDir'.*=>" config/config_defaults.php | cut -f 2 -d '>' | cut -f 2 -d "'" )
datacustom=$( grep "'workDir'.*=>" config/config_custom.php | cut -f 2 -d '>' | cut -f 2 -d "'" )
CI_WORKDIR=${datacustom:-$datadefault}
if [ -z "$CI_WORKDIR" ]; then
echo "ERROR: Unable to parse working dir from config/config_*.php."
echo " Sorry ... it is Bash here :-/"
exit 1
fi
builddir="$CI_WORKDIR/build/"
# ----------------------------------------------------------------------
# detect builds on error
# ----------------------------------------------------------------------
ls $builddir >/dev/null || exit 1
echo "Searching for builds im $builddir..."
founddirs=$( find $builddir -maxdepth 2 -type d | grep '2[0-1][0-9][0-9][0-1][0-9][0-3][0-9]' | sort )
if [ -z "$founddirs" ]; then
echo "Good news: No build dirs (builds on error) were found. Aborting."
echo
exit 0
fi
# ----------------------------------------------------------------------
# enter my directory
# ----------------------------------------------------------------------
cat <<ENDINFO
Found error builds: $( echo "$founddirs" | wc -l )
The latest error is the last entry per project.
Select a directory to jump in or press just RETURN to abort:
$( echo "$founddirs" | sed 's,^, ,g')
ENDINFO
echo -n "I want to jump to > "
read -r DIR_APPROOT
test -z "$DIR_APPROOT" && exit 1
# DIR_APPROOT="/var/imldeployment/build/$DIR_APPROOT"
ls "$DIR_APPROOT" >/dev/null || exit 2
# ----------------------------------------------------------------------
# prepare environment an GO!
# ----------------------------------------------------------------------
export DIR_APPROOT
export GIT_SSH="$CI_APPROOT/shellscripts/gitsshwrapper.sh"
export DIR_SSH_KEYS="$CI_WORKDIR/data/sshkeys"
export NVMINIT="$CI_APPROOT/shellscripts/nvm_init.sh";
export RVMSCRIPT="/usr/local/rvm/scripts/rvm";
cd "$DIR_APPROOT"
cat <<EOF
* Switching now into build dir
$( pwd )
* The environment for the CI server is set
You can go to the ./hooks/ directory to execute the command of your onbuild actions.
EOF
echo
bash --rcfile <(cat ~/.bashrc 2>/dev/null; echo 'PS1="CI|$PS1"')
# ----------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment