Script to build angular website.

if [ $# -gt 0 ]
then
#echo "$# Arguments passed.. : " $*
branchtobuild=$1
else
#echo "NO Arguments have been passed.. "
branchtobuild="master"
fi
WRKDIR=/home/rajaram_class_gmail_com/jenkinswrkdir
cd $WRKDIR
name=$(date '+%Y%m%d_%H%M%S');echo $name
Check if the needed directories exist
[ -d stage01 ] || echo "stage01"
[ -d stage02 ] || echo "stage02"
cd $WRKDIR/stage01
git init
git pull https://<userid>:<password>@bitbucket.org/soubhikg1894/stratfit.git stratfitpdc
git clone -b $branchtobuild --single-branch https://rajaramk8:6fmQE2UkhwAxYfLAbguf@bitbucket.org/soubhikg1894/stratfit.git
cp -R stratfit/StratfitWeb/* $WRKDIR/stage02
cd $WRKDIR/stage02
cp $WRKDIR/Dockerfile .
#
Change the code so that the call will go to the new qa server..
#
#

sed 's/stratfit.net\/services/stratfitqa.hopto.org/g' $WRKDIR/stage01/stratfit/StratfitWeb/src/app/components/api/config.ts > $WRKDIR/stage02/src/app/components/api/config.ts
ls $WRKDIR/stage02/src/app/service/rest.service.ts
sed 's/stratfit.net\/services/stratfitqa.hopto.org/g' $WRKDIR/stage01/stratfit/StratfitWeb/src/app/service/rest.service.ts > $WRKDIR/stage02/src/app/service/rest.service.ts
yes | rm -r $WRKDIR/stage01/stratfit
docker build -t stratfitqadocimg_$name . -f Dockerfile
retcode=$?
if [ $retcode -eq 0 ]
then
#
# stop any running containers..
#
for cont in docker container ls --format " {{.Names}}"
do
if [ $cont == "stratfitqa-" ]; then
#echo $cont
docker stop $cont
fi
done
# Now run the docker image we just now built.
docker run --name stratfitqa-$name -d -p 80:80 stratfitqadocimg_$name
# why did we remove e9bca15b1bd0? its sonarqube container.
docker ps -q |grep -v e9bca15b1bd0 > /home/rajaram_class_gmail_com/jenkinswrkdir/gooddockerimage.txt
else
echo "Sorry Build failed.. please check the error logs 😦 "
fi

Leave a comment

Design a site like this with WordPress.com
Get started