-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
73 lines (67 loc) · 2.02 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
def dockerImage = "maven:3-jdk-8"
def dockerArgs(env) { return "-e JAVA_TOOL_OPTIONS=-Duser.home=${env.WORKSPACE}"; }
pipeline {
agent any
triggers {
pollSCM('H * * * 1-5')
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
timeout time: 60, unit: 'MINUTES'
}
environment {
SONAR_TOKEN=credentials('sonar-token')
ARTIFACTORY_DEPLOY=credentials('artifactory-deploy')
}
stages {
stage('Build') {
agent {
docker {
image dockerImage
reuseNode true
args dockerArgs(env)
}
}
steps {
sh 'mvn -B clean package -Dmaven.test.failure.ignore'
}
post {
always {
recordIssues(tools: [mavenConsole(), java()])
junit "**/target/surefire-reports/*.xml"
jacoco()
}
}
}
stage('Sonar & Deploy') {
agent {
docker {
image dockerImage
reuseNode true
args dockerArgs(env)
}
}
//NOTE: sonar scan is only done for master branch because current Sonar instance does not support branching
when { branch 'master' }
steps {
sh 'mvn -B sonar:sonar deploy -s deploy-settings.xml -DskipTests -DskipITs -Dsonar.host.url=http://sonar.ceon.pl -Dsonar.login=${SONAR_TOKEN}'
}
}
}
post {
unstable {
emailext (
subject: "Build unstable in Jenkins: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
body: "Unstable job '${env.JOB_NAME}' #${env.BUILD_NUMBER}: check console output at ${env.BUILD_URL}.",
recipientProviders: [developers()]
)
}
failure {
emailext (
subject: "Build failed in Jenkins: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
body: "Failed job '${env.JOB_NAME}' #${env.BUILD_NUMBER}: check console output at ${env.BUILD_URL}.",
recipientProviders: [developers()]
)
}
}
}