-
Notifications
You must be signed in to change notification settings - Fork 9
/
Jenkinsfile
48 lines (46 loc) · 1.81 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
pipeline {
agent any
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '1', daysToKeepStr: '', numToKeepStr: '10')
disableConcurrentBuilds()
}
stages {
stage('Build') {
when {
not { branch 'master' }
}
steps {
withMaven(maven:'maven-3', jdk:'java-8', mavenLocalRepo: '.repository') {
sh 'mvn verify'
}
}
}
stage('Release') {
when {
branch 'master'
}
steps {
withMaven(maven:'maven-3', jdk:'java-8', mavenLocalRepo: '.repository') {
sh 'mvn release:clean git-timestamp:setup-release release:prepare release:perform'
}
}
post {
success {
// Publish the tag
sshagent(['github-ssh']) {
// using the full url so that we do not care if https checkout used in Jenkins
sh 'git push [email protected]:cloudbeers/maven-continuous.git $(cat TAG_NAME.txt)'
}
// Set the display name to the version so it is easier to see in the UI
script { currentBuild.displayName = readFile('VERSION.txt').trim() }
// (If using a repository manager with staging support) Close staging repo
}
failure {
// Remove the local tag as there is no matching remote tag
sh 'test -f TAG_NAME.txt && git tag -d $(cat TAG_NAME.txt) && rm -f TAG_NAME.txt || true'
// (If using a repository manager with staging support) Drop staging repo
}
}
}
}
}