-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathJenkinsfile
59 lines (59 loc) · 1.64 KB
/
Jenkinsfile
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
pipeline {
agent any
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '3')
}
environment {
TOMCAT_CREDS=credentials('pi-ssh-key')
TOMCAT_SERVER="192.168.1.48"
ROOT_WAR_LOCATION="/home/pi/tools/apache-tomcat-10.1.18/webapps"
LOCAL_WAR_DIR="build/dist"
WAR_FILE="app-0.1.0.war"
}
stages {
stage('verify tooling') {
steps {
sh '''
java -version
./bld version
'''
}
}
stage('download') {
steps {
sh './bld download purge'
}
}
stage('compile') {
steps {
sh './bld clean compile'
}
}
stage('precompile') {
steps {
sh './bld precompile'
}
}
stage('test') {
steps {
sh './bld test'
}
}
stage('war') {
steps {
sh './bld war'
}
}
stage('copy the war file to the Tomcat server') {
steps {
sh '''
ssh -i $TOMCAT_CREDS $TOMCAT_CREDS_USR@$TOMCAT_SERVER "/home/pi/tools/apache-tomcat-10.1.18/bin/catalina.sh stop"
ssh -i $TOMCAT_CREDS $TOMCAT_CREDS_USR@$TOMCAT_SERVER "rm -rf $ROOT_WAR_LOCATION/ROOT; rm -f $ROOT_WAR_LOCATION/ROOT.war"
scp -i $TOMCAT_CREDS $LOCAL_WAR_DIR/$WAR_FILE $TOMCAT_CREDS_USR@$TOMCAT_SERVER:$ROOT_WAR_LOCATION/ROOT.war
ssh -i $TOMCAT_CREDS $TOMCAT_CREDS_USR@$TOMCAT_SERVER "chown $TOMCAT_CREDS_USR:$TOMCAT_CREDS_USR $ROOT_WAR_LOCATION/ROOT.war"
ssh -i $TOMCAT_CREDS $TOMCAT_CREDS_USR@$TOMCAT_SERVER "/home/pi/tools/apache-tomcat-10.1.18/bin/catalina.sh start"
'''
}
}
}
}