forked from infinispan/infinispan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-release
91 lines (78 loc) · 2.95 KB
/
Jenkinsfile-release
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env groovy
pipeline {
agent {
label 'slave-group-release'
}
parameters {
string(name: 'version', defaultValue: '0.0.0.Qualifier', description: 'Release version')
string(name: 'nextVersion', defaultValue: '', description: 'Next release (blank to stay on current SNAPSHOT)')
string(name: 'branch', defaultValue: 'master', description: 'Branch to release from')
}
options {
timeout(time: 3, unit: 'HOURS')
}
stages {
stage('Prepare') {
steps {
script {
env.MAVEN_HOME = tool('Maven')
env.MAVEN_OPTS = "-Xmx1g -XX:+HeapDumpOnOutOfMemoryError"
env.JAVA_HOME = tool('JDK 8')
env.JAVA10_HOME = tool('JDK 10')
}
sh returnStdout: true, script: 'cleanup.sh'
}
}
stage('Checkout') {
steps {
checkout scm
}
}
stage('Version') {
steps {
sh "$MAVEN_HOME/bin/mvn -B -V versions:set -DnewVersion=${version}"
}
}
stage('Create Staging repository') {
steps {
// Create a staging repository on Nexus
script {
STAGING_REPO_ID = sh(returnStdout: true, script: "$MAVEN_HOME/bin/mvn -B -V org.sonatype.plugins:nexus-staging-maven-plugin:rc-open -pl .|grep 'Opened '|grep -oE '[^ ]+\$'").trim()
}
echo "Staging repository: $STAGING_REPO_ID"
}
}
stage('Deploy') {
steps {
sh "$MAVEN_HOME/bin/mvn -B -V -Pdistribution -DskipTests clean deploy -DstagingRepositoryId=$STAGING_REPO_ID -Djava10.home=$JAVA10_HOME -Dinfinispan.brand.version=${version}"
}
}
stage('Close Staging repository') {
steps {
// This ensures that Nexus validates the repository for correctness
sh "$MAVEN_HOME/bin/mvn -B -V org.sonatype.plugins:nexus-staging-maven-plugin:rc-close -pl . -DstagingRepositoryId=$STAGING_REPO_ID"
}
}
stage('Tag') {
steps {
// Commit and tag once everything is good
sh "$MAVEN_HOME/bin/mvn -B -V scm:checkin -Dmessage=\"Releasing version ${version}\" -DpushChanges=false"
sh "$MAVEN_HOME/bin/mvn -B -V scm:tag"
}
}
}
post {
always {
// Clean
sh 'git clean -fdx -e "*.hprof" || echo "git clean failed, exit code $?"'
}
failure {
echo "post build status: failure"
emailext to: '${DEFAULT_RECIPIENTS}', subject: '${DEFAULT_SUBJECT}', body: '${DEFAULT_CONTENT}'
}
success {
echo "post build status: success"
emailext to: '${DEFAULT_RECIPIENTS}', subject: '${DEFAULT_SUBJECT}', body: '${DEFAULT_CONTENT}'
}
}
}