forked from GHCdemo/Demo-WorkSheets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-add-sonar-stage
65 lines (55 loc) · 1.73 KB
/
Jenkinsfile-add-sonar-stage
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
def call() {
pipeline {
agent any
tools {
jdk 'jdk8'
}
environment{
server = null
rtMaven = null
buildInfo = null
scannerHome = tool 'sonar-scanner'
}
stages {
stage ('Initialize') {
steps {
script{
server = Artifactory.newServer url: 'http://localhost:8081/artifactory', username: 'admin', password: 'admin'
rtMaven = Artifactory.newMavenBuild()
rtMaven.resolver server: server, releaseRepo: 'all-repo', snapshotRepo: 'all-repo'
rtMaven.deployer server: server, releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local'
rtMaven.deployer.deployArtifacts = false
rtMaven.tool = 'maven-3.5.4'
}
}
}
stage ('Build') {
steps {
script{
buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean install'
}
}
post {
success {
junit 'target/surefire-reports/**/*.xml'
}
}
}
stage ('Sonar Analysis') {
steps {
withSonarQubeEnv('local-sonarqube') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
stage('Publish'){
steps{
script{
rtMaven.deployer.deployArtifacts buildInfo
server.publishBuildInfo buildInfo
}
}
}
}
}
}