-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
64 lines (63 loc) · 2.31 KB
/
Copy pathJenkinsfile
File metadata and controls
64 lines (63 loc) · 2.31 KB
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
pipeline {
agent any
stages {
stage('Build') {
steps {
echo '----- Build app -----'
withMaven (maven: 'Maven') {
withCredentials([]) {
sh 'mvn clean compile'
}
}
}
}
stage('Testing') {
steps {
echo '----- Test app -----'
withMaven (maven: 'Maven') {
sh 'mvn test'
}
}
}
stage('Static Analysis') {
steps {
withMaven(maven: 'Maven') {
withSonarQubeEnv(installationName:'Sonarqube-NatureOps', credentialsId: 'sonar-token') {
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
sh 'mvn sonar:sonar \
-Dsonar.host.url=https://sonarqube.natureops.eus \
-Dsonar.login=${SONAR_TOKEN} \
-Dsonar.sources=src/main/resources,src/main/java \
-Dsonar.tests=src/test \
-Dsonar.java.coveragePlugin=jacoco \
-Dsonar.dynamicAnalysis=reuseReports'
}
}
}
}
}
stage('QualityGate') {
steps {
timeout(time: 5, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true, credentialsId: 'sonar-webhook'
}
}
}
stage('Deploy') {
when {
branch 'master'
}
steps {
echo '----- Deploy app -----'
withMaven (maven: 'Maven') {
withCredentials([]) {
sh 'mvn -Dmaven.test.skip package'
}
}
script {
deploy adapters: [tomcat9(credentialsId: 'tomcat-deploy-user', path: '', url: 'http://10.8.0.1:8080')], contextPath: '/', onFailure: false, war: '**/*.war'
}
}
}
}
}