forked from infinispan/infinispan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-release
128 lines (112 loc) · 4.91 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/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)')
gitParameter(name: 'branch', defaultValue: 'origin/master', branchFilter: 'origin/(.*)', type: 'PT_BRANCH', description: 'Branch to release from')
}
options {
timeout(time: 3, unit: 'HOURS')
timestamps()
buildDiscarder(logRotator(numToKeepStr: '100', daysToKeepStr: '61'))
}
stages {
stage('Prepare') {
steps {
script {
env.MAVEN_HOME = tool('Maven')
env.MAVEN_OPTS = "-Xmx1g -XX:+HeapDumpOnOutOfMemoryError"
env.JAVA_HOME = tool('JDK 11')
}
sh returnStdout: true, script: 'cleanup.sh'
}
}
stage('Checkout') {
steps {
checkout scm
}
}
stage('Commit Proto.lock Files') {
steps {
script {
if ("${version}".endsWith('Final')) {
configFileProvider([configFile(fileId: 'maven-settings-with-deploy-snapshot', variable: 'MAVEN_SETTINGS')]) {
sh "$MAVEN_HOME/bin/mvn clean install -B -V -e -s $MAVEN_SETTINGS -DskipTests -DcommitProtoLockChanges=true"
}
sh "git add '**/proto.lock'"
sh "git diff-index --quiet HEAD || git commit -m 'Committing proto.lock files for ${version}'"
}
}
}
}
stage('Commit version for documentation') {
steps {
script {
sh "sed -i \"s/^:ispn_version:.*\$/:ispn_version: ${version}/\" documentation/src/main/asciidoc/topics/attributes/community-attributes.adoc"
sh "git add 'documentation/src/main/asciidoc/topics/attributes/community-attributes.adoc'"
sh "git diff-index --quiet HEAD || git commit -m 'Committing ${version} to doc attribute file'"
}
}
}
stage('Version') {
steps {
sh "$MAVEN_HOME/bin/mvn -B -V versions:set -DnewVersion=${version} -DprocessAllModules=true"
sh "$MAVEN_HOME/bin/mvn -B -V versions:set-property -Dproperty=version.infinispan -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 -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 -Dtag=${version}"
}
}
stage('Next version') {
when {
expression { params.nextVersion != '' }
}
steps {
sh "$MAVEN_HOME/bin/mvn -B -V versions:set -DnewVersion=${nextVersion} -DprocessAllModules=true"
sh "$MAVEN_HOME/bin/mvn -B -V versions:set-property -Dproperty=version.infinispan -DnewVersion=${nextVersion}"
sh "$MAVEN_HOME/bin/mvn -B -V -Dmessage='next version ${nextVersion}' -DscmVersion=${branch} -DscmVersionType=branch scm:checkin"
}
}
}
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}'
}
}
}