Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
4958 rajveer 1
#!/bin/bash
2
 
3
FROMEMAIL="build@shop2020.in"
4
FROMPASSWORD="cafe@nes"
7230 amit.gupta 5
TOEMAIL="rajveer.singh@shop2020.in,anupam.singh@shop2020.in,amar.kumar@shop2020.in"
4958 rajveer 6
MESSAGE=""
7
FILE="/var/log/build-staging.log"
5668 amit.gupta 8
SHOP2020_SERVER="shop2020.in"
4958 rajveer 9
DATE=`date +%Y-%b-%d-%Hh%Mm%Ss`
5103 mandeep.dh 10
MAVEN_REPO="${HOME}/.m2/repository"
4958 rajveer 11
 
12
build()
13
{
14
  /opt/apache-maven-3.0.3/bin/mvn clean install -P minify -Ddomain.name=shop2020.in -Denv=staging >>$FILE 2>&1;
15
  OUT=$?
16
  if [ $OUT -eq 0 ];then
17
     buildpythonpackages
18
  else
19
     MESSAGE="Maven build failed"
20
     sendmail
21
  fi
22
}
23
 
24
buildpythonpackages()
25
{
26
  cd /root/code/trunk/PyProj/src;
27
  python setup.py bdist_egg;
28
  OUT=$?
29
  if [ $OUT -eq 0 ];then
30
    copycontent
31
  else
32
    MESSAGE="Python egg packing failed"
33
    sendmail
34
  fi
35
}
36
 
37
deployWar()
38
{
39
  ssh ${SHOP2020_SERVER} "/root/code/trunk/runutils/deploy-everything.sh DEPLOY"
40
  OUT=$?
41
  if [ $OUT -eq 0 ];then
42
     MESSAGE="War deployed properly"
43
  else
44
     MESSAGE="Copying content failed"
45
  fi
46
  sendmail
47
}
48
copycontent()
49
{
50
  ssh ${SHOP2020_SERVER} "mkdir /catalog-dumps/\"${DATE}\""
51
  scp ${MAVEN_REPO}/in/shop2020/Website/1.0-SNAPSHOT/Website-1.0-SNAPSHOT.war ${SHOP2020_SERVER}:/catalog-dumps/${DATE}/Website-1.0-SNAPSHOT.war
52
  scp /root/code/trunk/PyProj/src/dist/PyProj-0.1-py2.6.egg ${SHOP2020_SERVER}:/catalog-dumps/${DATE}/PyProj-0.1-py2.6.egg
53
  ssh ${SHOP2020_SERVER} "echo \"${DATE}\">/catalog-dumps/latest.build"
54
  OUT=$?
55
  if [ $OUT -eq 0 ];then
56
     deployWar
57
  else
58
     MESSAGE="Copying content failed"
59
  fi
60
}
61
 
62
sendmail()
63
{
64
  if [ $OUT -eq 0 ];then
5103 mandeep.dh 65
    SUBJECT="Build and deployment is successful on shop2020"
4958 rajveer 66
  else
67
    SUBJECT="Build failed or deployment failed."
68
  fi
69
 
70
  sendEmail -f "$FROMEMAIL" -s smtp.gmail.com:587 -xu "$FROMEMAIL" -xp "$FROMPASSWORD" -t $TOEMAIL -o tls=yes -u "$SUBJECT" -m "$MESSAGE" -a $FILE
71
}
72
 
73
cd /root/code/trunk;
74
svn up;
75
OUT=$?
76
if [ $OUT -eq 0 ];then
77
  build
78
else
79
  MESSAGE="Svn update failed"
80
  sendmail
81
fi
82