-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
77 lines (74 loc) · 2.7 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
74
75
76
77
pipeline {
agent { node { label 'srs-build01' } }
tools {
maven 'maven3'
jdk 'jdk8'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
}
parameters {
booleanParam(name: "RELEASE",
description: "If selected, build a release from current commit. Otherwise build currrent commit.",
defaultValue: false)
string(name: 'RELEASE_VERSION', defaultValue: '', description: 'If RELEASE is selected, the Release Version (e.g. 2.1)')
}
stages {
stage ('Build') {
steps {
sh 'mvn -s /nfs/slac/g/srs/hudson/hudson-settings-srs.xml -U clean verify'
}
post {
always {
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
junit testResults: '**/target/surefire-reports/**/*.xml', allowEmptyResults: true
}
}
}
stage ('Deploy') {
when {
branch 'master'
}
steps {
sh 'mvn -s /nfs/slac/g/srs/hudson/hudson-settings-srs.xml -U validate jar:jar deploy:deploy'
}
}
stage('Release') {
when {
expression { params.RELEASE }
branch 'master'
}
steps {
script {
currentBuild.displayName = "${RELEASE_VERSION}"
}
// Always need a symbolic ref for maven release
sh "mvn -s /nfs/slac/g/srs/hudson/hudson-settings-srs.xml \
-PHudson -U -Dresume=false \
release:prepare \
release:perform \
-DreleaseVersion=${RELEASE_VERSION} \
"
}
post {
success {
withCredentials([usernamePassword(credentialsId: "feb9edc9-2596-4e5a-aba9-0fc8222f7ef3", passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USER')]) {
// Setup credentials helper so we can get credentials
sh """git config credential.helper '!f() { sleep 1; echo "username=${GIT_USER}"; echo "password=${GIT_PASSWORD}"; }; f'"""
sh "git push origin org-srs-datacat-${RELEASE_VERSION}"
}
}
}
}
}
post {
failure {
emailext recipientProviders: [brokenTestsSuspects(), brokenBuildSuspects(), developers()],
subject: '${DEFAULT_SUBJECT}',
body: '${DEFAULT_CONTENT}'
}
always {
deleteDir()
}
}
}