Subversion Repositories SmartDukaan

Rev

Rev 5964 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/bin/bash

FROMEMAIL="build@shop2020.in"
FROMPASSWORD="cafe@nes"
TOEMAIL="mandeep.dhir@shop2020.in,rajveer.singh@shop2020.in"
MESSAGE=""
FILE="/var/log/build.log"

build()
{
  /opt/apache-maven-3.0.3/bin/mvn clean install -P minify -Ddomain.name=saholic.com -Denv=prod >>$FILE 2>&1;
  OUT=$?
  if [ $OUT -eq 0 ];then
     buildpythonpackages
  else
     MESSAGE="Maven build failed"
     sendmail
  fi
}

buildpythonpackages()
{
  cd /root/code/trunk/PyProj/src;
  python setup.py bdist_egg;
  OUT=$?
  if [ $OUT -eq 0 ];then
    copycontent
  else
    MESSAGE="Python egg packing failed"
    sendmail
  fi
}

copycontent()
{
  cd /root/code/trunk/runutils;
  ./copy-wars-to-production.sh >>$FILE
  OUT=$?
  if [ $OUT -eq 0 ];then
     MESSAGE="Build process completed"
  else
     MESSAGE="Copying content failed"
  fi
  sendmail
}

sendmail()
{
  if [ $OUT -eq 0 ];then
    SUBJECT="Build Successful"
  else
    SUBJECT="Build failed"
  fi

  sendEmail -f "$FROMEMAIL" -s smtp.gmail.com:587 -xu "$FROMEMAIL" -xp "$FROMPASSWORD" -t $TOEMAIL -o tls=yes -u "$SUBJECT" -m "$MESSAGE" -a $FILE
}

cd /root/code/trunk;
svn up;
OUT=$?
if [ $OUT -eq 0 ];then
  build
else
  MESSAGE="Svn update failed"
  sendmail
fi