-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
117 lines (111 loc) · 4.04 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
pipeline {
agent any
environment {
SERVER_IP = sh(script: 'curl -s http://169.254.169.254/latest/meta-data/public-ipv4', returnStdout: true).trim()
}
tools {
maven 'my_mvn'
}
stages {
stage("Checkout") {
steps {
git branch: 'main', url: 'https://github.com/nholuongut/manik-calculator.git'
// git branch: '8.1-addressbook', url: 'https://github.com/manikcloud/Jenkins-cicd.git'
}
}
stage('Maven Clean') {
steps {
sh "mvn clean"
}
}
stage('Maven Build') {
steps {
sh "mvn compile"
}
}
stage("Unit Test") {
steps {
sh "mvn test"
}
}
stage("Unit validate") {
steps {
sh "mvn validate"
}
}
// stage("Unit Verify") {
// steps {
// sh "mvn verify"
// }
// }
stage('Publish Unit Test Report') {
steps {
junit 'target/surefire-reports/*.xml'
}
}
// stage("SonarQube Analysis") {
// steps {
// withCredentials([usernamePassword(credentialsId: 'sonarqube', passwordVariable: 'password', usernameVariable: 'username')]) {
// withSonarQubeEnv('sonarqube-server') {
// sh "mvn verify sonar:sonar -Dsonar.host.url=http://${SERVER_IP}:9000 -Dsonar.login=${username} -Dsonar.password=${password}"
// }
// }
// }
// }
stage("Maven Package") {
steps {
sh "mvn package"
}
}
// stage("Checkstyle") {
// steps {
// sh "mvn checkstyle:checkstyle"
// checkstyle canComputeNew: true, defaultEncoding: '', healthy: '', pattern: 'target/checkstyle-result.xml', unHealthy: ''
// }
// }
stage('Build and Static Analysis') {
steps {
sh 'mvn checkstyle:checkstyle'
recordIssues tools: [checkStyle(pattern: '**/checkstyle-result.xml')]
}
}
stage('FindBugs Analysis') {
steps {
sh 'mvn findbugs:findbugs'
recordIssues tools: [findBugs(pattern: '**/findbugsXml.xml')]
}
}
// stage("FindBugs Analysis") {
// steps {
// sh "mvn findbugs:findbugs"
// findbugs pattern: 'target/findbugsXml.xml'
// }
// }
// stage("Deploy On Server") {
// steps {
// deploy adapters: [tomcat9(credentialsId: 'tomcat-9', path: '', url: "http://${SERVER_IP}:8090")], contextPath: '/manik-calculator', war: '**/target/*.war'
// }
// }
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
success {
echo "App URL: http://${SERVER_IP}:8090/manik-calculator/"
// emailext (
// to: 'varunmanik1@gmail.com',
// subject: "SUCCESS: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
// body: "The job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' completed successfully."
// )
}
failure {
echo "Failed to deploy application to http://${SERVER_IP}:8090/manik-calculator/"
// emailext (
// to: 'varunmanik1@gmail.com',
// subject: "FAILURE: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
// body: "The job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' failed."
// )
}
}
}