I am writing a script for automatic deployment. Below is the code.
# ! /bin/bash
#Banner function
banner() {
msg="# $* #"
edge=$(echo "$msg" | sed 's/./#/g')
echo "$edge"
echo "$msg"
echo "$edge"
}
#Becoming sudo
sudo -Hiu lvadmin
cd /home/lvadmin/lvsvnprojects/QAUat/LV-Tools
#checking if there are any commits
str=$(git status)
if [[ $str =~ .*Your\ branch\ is\ behind ]]; then
echo -e `date "+%Y-%m-%d %H:%M:%S"` "\033[33;5mCode is outdated.Getting latest changes\033[0m\n\n"
#checking if pull is successful.
if git pull; then
echo "OK"
else
echo "Problem while pulling the code."
exit
fi
else
echo "Code is up to date"
fi
ls
gradle build # This will build and exits the process.
cd /home/lvadmin/apache-tomcat-9.0.64/bin # process is stopped and this command doesnt execute
pwd
Kindly help me out in knowing the thing which im missing here.
Also, im unable to store the output value of gradle build into a variable.Like the way i did for git status. When i try to store its output, gradle build is not running.