-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.groovy
80 lines (74 loc) · 2.75 KB
/
Jenkinsfile.groovy
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
pipeline {
agent any
stages {
stage('build') {
steps {
sh '''
chmod 755 gradlew
./gradlew clean compileQuerydsl build -PskipAsciidoctor
'''
}
}
stage('test') {
steps {
sh './gradlew test'
}
}
stage('SonarQube analysis') {
steps {
withSonarQubeEnv('SonarQube-server') {
sh './gradlew sonarqube'
}
}
}
stage('deploy') {
steps {
deploy adapters: [tomcat9(credentialsId: 'deployer_user', path: '', url: 'http://13.209.72.244:8080/')], contextPath: null, war: '**/*.war'
deploy adapters: [tomcat9(credentialsId: 'deployer_user', path: '', url: 'http://13.125.81.206:8080/')], contextPath: null, war: '**/*.war'
}
}
// stage('restart tomcat') {
// steps {
// script {
// sshagent(credentials: ['tomcat']) {
// sh '''
// ssh [email protected] '
// TOMCAT_PID=$(ps -ef | grep tomcat | grep -v grep | awk '"'"'{print $2}'"'"')
// if [[ -n $TOMCAT_PID ]]; then
// echo "Tomcat is running with PID $TOMCAT_PID, stopping..."
// sudo kill -15 $TOMCAT_PID
// while ps -p $TOMCAT_PID > /dev/null; do sleep 1; done
// echo "Tomcat stopped."
// else
// echo "Tomcat is not running."
// fi
// echo "Starting Tomcat..."
// cd /opt/apache-tomcat-9.0.86/
// sudo ./bin/startup.sh
// echo "Tomcat started."
// '
// '''
// }
// }
// }
// }
}
post {
success {
script {
emailext(
to: '[email protected]',
subject: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>"""
)
}
}
failure {
echo "This will run if failed"
}
changed {
echo "This will run when the state of the pipeline has changed"
}
}
}