-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·87 lines (80 loc) · 2.39 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
#snapshot the DB if possible
#define vars
EAP6_DIR=/home/kanat/jboss-eap-6.0
PROJ_DIR=/home/kanat/git/kudos
FILE=/home/kanat/.isDeploying
#define redeploy function
redeployKudos(){
$EAP6_DIR/bin/jboss-cli.sh --connect <<END
undeploy lrs.war --all-relevant-server-groups
undeploy sms.war --all-relevant-server-groups
undeploy lms.war --all-relevant-server-groups
undeploy jbpm-service.jar --all-relevant-server-groups
undeploy persistence.jar --all-relevant-server-groups
deploy $PROJ_DIR/persistence/build/libs/persistence.jar --all-server-groups
deploy $PROJ_DIR/jbpm-service/build/libs/jbpm-service.jar --all-server-groups
deploy $PROJ_DIR/lrs/build/libs/lrs.war --server-groups=lrs-server-group
deploy $PROJ_DIR/sms/build/libs/sms.war --server-groups=sms-server-group
deploy $PROJ_DIR/lms/build/libs/lms.war --server-groups=lms-server-group
quit
END
}
if [ -e "$FILE" ]; then
#sendmail -t << EOF
#from:[email protected]
#subject:JBOSS ERROR
#Jboss is not responding
#EOF
echo "JBOSS ERROR"
else
touch $FILE
echo $$ > $FILE
cd $PROJ_DIR
git fetch origin
LOCAL_REV="$(git log -n1 --format=format:%H refs/heads/master)"
REMOTE_REV="$(git log -n1 --format=format:%H refs/remotes/origin/master)"
echo $LOCAL_REV $REMOTE_REV
if [ $LOCAL_REV = $REMOTE_REV ]; then
echo `date`: 'No changes, nothing to do'
else
echo 'Remote has some changes'
if git checkout master && git pull --ff-only origin master && git checkout prod && git rebase master
then
#gradle reexplode, etc..
gradle lrs:assemble
gradle sms:assemble
gradle lms:assemble
#jboss-cli undeploy and deploy
if redeployKudos
then
MESSAGE=`git log "$LOCAL_REV..$REMOTE_REV"`
#sendmail -t <<EOF
#from:[email protected]
#subject:Commits successfully deployed.
#$MESSAGE
#EOF
echo "SUCCSESSFULL DEPLOY"
else
echo "DEPLOYMENT ERROR"
#sendmail -t << EOF
#from:[email protected]
#subject:DEPLOYMENT ERROR
#There is an error, while deploy
#EOF
fi
else
echo "GIT ERROR"
#sendmail -t << EOF
#from:[email protected]
#subject:GIT ERROR
#There is an error, while rebase
#EOF
fi
fi
rm $FILE
fi