-
Notifications
You must be signed in to change notification settings - Fork 125
/
Jenkinsfile
34 lines (25 loc) · 974 Bytes
/
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
node('master') {
def MVNHOME = tool 'Maven3'
stage ('checkout code'){
checkout scm
}
stage ('build'){
sh "${MVNHOME}/bin/mvn clean install"
}
stage ('Test Cases Execution'){
sh "${MVNHOME}/bin/mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Pcoverage-per-test"
}
stage ('Sonar Analysis'){
//sh 'mvn sonar:sonar -Dsonar.host.url=http://localhost:9000/sonar'
}
stage('Code Coverage ') {
//sh "curl -o coverage.json 'http://35.154.151.174:9000/sonar/api/measures/component?componentKey=com.java.example:java-example&metricKeys=coverage';sonarCoverage=`jq '.component.measures[].value' coverage.json`;if [ 1 -eq '\$(echo '\${sonarCoverage} >= 50'| bc)' ]; then echo 'Failed' ;exit 1;else echo 'Passed'; fi"
}
stage ('Archive Artifacts'){
archiveArtifacts artifacts: 'target/*.war'
}
input message: "QA Team Approval for Production Deployment?"
stage ('Production Deployment'){
sh 'cp target/*.war /opt/apache-tomcat-8.5.16/webapps'
}
}