-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
67 lines (57 loc) · 2.08 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
#!groovy
import hudson.plugins.emailext.plugins.recipients.*;
node{
try {
currentBuild.result = 'SUCCESS'
def mycfg_file = 'df97f4a9-f259-4138-bead-21720f9c3b46'
stage('Checkout sources & clean') {
checkout scm
echo 'run task --> mvn clean -U'
sh '''mvn clean -U'''
}
try {
stage('Build & UT') {
echo 'run task --> mvn install'
sh '''mvn install'''
}
} catch (err) {
currentBuild.result = 'UNSTABLE'
println err
}
try {
stage ('Sonar analysis'){
echo 'run task --> mvn sonar:sonar'
sh '''mvn sonar:sonar'''
}
stage('Deploy') {
configFileProvider([configFile(fileId: mycfg_file, variable: 'GLOBAL_MAVEN_SETTINGS')]) {
echo "'settings.xml' path: $GLOBAL_MAVEN_SETTINGS"
echo "run task --> mvn -s $GLOBAL_MAVEN_SETTINGS jar:jar deploy:deploy"
sh '''mvn -s $GLOBAL_MAVEN_SETTINGS jar:jar deploy:deploy'''
}
}
} catch (err) {
currentBuild.result = 'UNSTABLE'
echo 'An error has occurred. Build status is ' + "${currentBuild.result}"
println err
}
} catch (err) {
currentBuild.result = 'FAILURE'
echo 'An error has occurred. Build status is ' + "${currentBuild.result}"
println err
} finally {
stage('Email notification'){
// temporary workaround
RecipientProviderUtilities.SEND_TO_UNKNOWN_USERS = true
emailext(
subject: "[TAO-JENKINS] Jenkins build '${env.JOB_NAME}[#${env.BUILD_NUMBER}]' status is [${currentBuild.result}]",
body: "See: ${env.BUILD_URL}",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}
}
}
def version() {
def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'
return matcher ? matcher[0][1] : null
}