1
+ #! /usr/bin/groovy
2
+ /*
3
+ * Hibernate, Relational Persistence for Idiomatic Java
4
+ *
5
+ * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
6
+ * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
7
+ */
8
+
9
+ /*
10
+ * See https://github.com/hibernate/hibernate-jenkins-pipeline-helpers
11
+ */
12
+
13
+
14
+ // Avoid running the pipeline on branch indexing
15
+ if (currentBuild. getBuildCauses(). toString(). contains(' BranchIndexingCause' )) {
16
+ print " INFO: Build skipped due to trigger being Branch Indexing"
17
+ currentBuild. result = ' ABORTED'
18
+ return
19
+ }
20
+
21
+ env. PROJECT = " orm"
22
+ env. JIRA_KEY = " HHH"
23
+
24
+ pipeline {
25
+ agent {
26
+ label ' Worker&&Containers'
27
+ }
28
+ tools {
29
+ jdk ' OpenJDK 11 Latest'
30
+ }
31
+ options {
32
+ buildDiscarder logRotator(daysToKeepStr : ' 30' , numToKeepStr : ' 10' )
33
+ rateLimitBuilds(throttle : [count : 1 , durationName : ' day' , userBoost : true ])
34
+ disableConcurrentBuilds(abortPrevious : false )
35
+ preserveStashes()
36
+ }
37
+ parameters {
38
+ string(
39
+ name : ' RELEASE_VERSION' ,
40
+ defaultValue : ' ' ,
41
+ description : ' The version to be released, e.g. 6.2.1.Final.' ,
42
+ trim : true
43
+ )
44
+ string(
45
+ name : ' DEVELOPMENT_VERSION' ,
46
+ defaultValue : ' ' ,
47
+ description : ' The next version to be used after the release, e.g. 6.2.2-SNAPSHOT.' ,
48
+ trim : true
49
+ )
50
+ booleanParam(
51
+ name : ' RELEASE_DRY_RUN' ,
52
+ defaultValue : false ,
53
+ description : ' If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts or documentation.'
54
+ )
55
+ }
56
+ stages {
57
+ stage(' Release check' ) {
58
+ steps {
59
+ script {
60
+ dir(' .release/scripts' ) {
61
+ checkout scmGit(branches : [[name : ' */main' ]], extensions : [], userRemoteConfigs : [[credentialsId : ' ed25519.Hibernate-CI.github.com' , url : ' https://github.com/hibernate/hibernate-release-scripts.git' ]])
62
+ }
63
+ // Determine version information for release process
64
+ env. CURRENT_VERSION = sh(
65
+ script : " .release/scripts/determine-current-version.sh ${ env.PROJECT} " ,
66
+ returnStdout : true
67
+ ). trim()
68
+
69
+ if ( params. RELEASE_VERSION == null || params. RELEASE_VERSION . isEmpty() ) {
70
+ env. RELEASE_VERSION = sh(
71
+ script : " .release/scripts/determine-release-version.sh ${ env.CURRENT_VERSION} " ,
72
+ returnStdout : true
73
+ ). trim()
74
+ }
75
+ else {
76
+ env. RELEASE_VERSION = params. RELEASE_VERSION
77
+ }
78
+ if ( params. DEVELOPMENT_VERSION == null || params. DEVELOPMENT_VERSION . isEmpty() ) {
79
+ env. DEVELOPMENT_VERSION = sh(
80
+ script : " .release/scripts/determine-development-version.sh ${ env.RELEASE_VERSION} " ,
81
+ returnStdout : true
82
+ ). trim()
83
+ }
84
+ else {
85
+ env. DEVELOPMENT_VERSION = params. DEVELOPMENT_VERSION
86
+ }
87
+ env. VERSION_BASIS = sh(
88
+ script : " .release/scripts/determine-version-basis.sh ${ env.RELEASE_VERSION} " ,
89
+ returnStdout : true
90
+ ). trim()
91
+ env. VERSION_FAMILY = sh(
92
+ script : " .release/scripts/determine-version-family.sh ${ env.RELEASE_VERSION} " ,
93
+ returnStdout : true
94
+ ). trim()
95
+ env. NEXT_VERSION_BASIS = sh(
96
+ script : " .release/scripts/determine-version-basis.sh ${ env.DEVELOPMENT_VERSION} " ,
97
+ returnStdout : true
98
+ ). trim()
99
+ env. SCRIPT_OPTIONS = params. RELEASE_DRY_RUN ? " -d" : " "
100
+ echo " Workspace version: ${ env.CURRENT_VERSION} "
101
+ echo " Release version: ${ env.RELEASE_VERSION} "
102
+ echo " Development version: ${ env.DEVELOPMENT_VERSION} "
103
+ echo " Version family: ${ env.VERSION_FAMILY} "
104
+
105
+ // Determine version id to check if Jira version exists
106
+ sh(script : " .release/scripts/determine-jira-version-id.sh ${ env.JIRA_KEY} ${ env.VERSION_BASIS} " , returnStdout : true )
107
+ }
108
+ }
109
+ }
110
+ stage(' Release prepare' ) {
111
+ steps {
112
+ script {
113
+ dir(' .release/scripts' ) {
114
+ checkout scmGit(branches : [[name : ' */main' ]], extensions : [], userRemoteConfigs : [[credentialsId : ' ed25519.Hibernate-CI.github.com' , url : ' https://github.com/hibernate/hibernate-release-scripts.git' ]])
115
+ }
116
+ configFileProvider([configFile(fileId : ' release.config.ssh' , targetLocation : " ${ env.HOME} /.ssh/config" ), configFile(fileId : ' release.config.ssh.knownhosts' , targetLocation : " ${ env.HOME} /.ssh/known_hosts" )]) {
117
+ withCredentials([
118
+ usernamePassword(credentialsId : ' ossrh.sonatype.org' , passwordVariable : ' OSSRH_PASSWORD' , usernameVariable : ' OSSRH_USER' ),
119
+ usernamePassword(credentialsId : ' gradle-plugin-portal-api-key' , passwordVariable : ' PLUGIN_PORTAL_PASSWORD' , usernameVariable : ' PLUGIN_PORTAL_USERNAME' ),
120
+ file(credentialsId : ' release.gpg.private-key' , variable : ' RELEASE_GPG_PRIVATE_KEY_PATH' ),
121
+ string(credentialsId : ' release.gpg.passphrase' , variable : ' RELEASE_GPG_PASSPHRASE' )
122
+ ]) {
123
+ sshagent([' ed25519.Hibernate-CI.github.com' , ' hibernate.filemgmt.jboss.org' , ' hibernate-ci.frs.sourceforge.net' ]) {
124
+ // set release version
125
+ // update changelog from JIRA
126
+ // tags the version
127
+ // changes the version to the provided development version
128
+ sh " .release/scripts/prepare-release.sh ${ env.PROJECT} ${ env.RELEASE_VERSION} ${ env.DEVELOPMENT_VERSION} "
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ // Done through Jira Automation
136
+ // stage('Jira release') {
137
+ // steps {
138
+ // script {
139
+ // dir('.release/scripts') {
140
+ // checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'ed25519.Hibernate-CI.github.com', url: 'https://github.com/hibernate/hibernate-release-scripts.git']])
141
+ // }
142
+ // withCredentials([usernameColonPassword(credentialsId: 'jira-automation', variable: 'JIRA_API_TOKEN')]) {
143
+ // sh ".release/scripts/jira-release.sh ${env.SCRIPT_OPTIONS} ${env.JIRA_KEY} ${env.VERSION_BASIS} ${env.NEXT_VERSION_BASIS}"
144
+ // }
145
+ // }
146
+ // }
147
+ // }
148
+ stage(' Publish release' ) {
149
+ steps {
150
+ script {
151
+ dir(' .release/scripts' ) {
152
+ checkout scmGit(branches : [[name : ' */main' ]], extensions : [], userRemoteConfigs : [[credentialsId : ' ed25519.Hibernate-CI.github.com' , url : ' https://github.com/hibernate/hibernate-release-scripts.git' ]])
153
+ }
154
+ configFileProvider([configFile(fileId : ' release.config.ssh' , targetLocation : " ${ env.HOME} /.ssh/config" ), configFile(fileId : ' release.config.ssh.knownhosts' , targetLocation : " ${ env.HOME} /.ssh/known_hosts" )]) {
155
+ withCredentials([
156
+ usernamePassword(credentialsId : ' ossrh.sonatype.org' , passwordVariable : ' OSSRH_PASSWORD' , usernameVariable : ' OSSRH_USER' ),
157
+ usernamePassword(credentialsId : ' gradle-plugin-portal-api-key' , passwordVariable : ' PLUGIN_PORTAL_PASSWORD' , usernameVariable : ' PLUGIN_PORTAL_USERNAME' ),
158
+ file(credentialsId : ' release.gpg.private-key' , variable : ' RELEASE_GPG_PRIVATE_KEY_PATH' ), string(credentialsId : ' release.gpg.passphrase' , variable : ' RELEASE_GPG_PASSPHRASE' )
159
+ ]) {
160
+ sshagent([' ed25519.Hibernate-CI.github.com' , ' hibernate.filemgmt.jboss.org' , ' hibernate-ci.frs.sourceforge.net' ]) {
161
+ // performs documentation upload and Sonatype release
162
+ // push to github
163
+ sh " .release/scripts/publish.sh ${ env.SCRIPT_OPTIONS} ${ env.PROJECT} ${ env.VERSION_BASIS} ${ env.NEXT_VERSION_BASIS} "
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
170
+ stage(' Website release' ) {
171
+ steps {
172
+ script {
173
+ dir(' .release/scripts' ) {
174
+ checkout scmGit(branches : [[name : ' */main' ]], extensions : [], userRemoteConfigs : [[credentialsId : ' ed25519.Hibernate-CI.github.com' , url : ' https://github.com/hibernate/hibernate-release-scripts.git' ]])
175
+ }
176
+ configFileProvider([configFile(fileId : ' release.config.ssh' , targetLocation : " ${ env.HOME} /.ssh/config" ), configFile(fileId : ' release.config.ssh.knownhosts' , targetLocation : " ${ env.HOME} /.ssh/known_hosts" )]) {
177
+ sshagent([' ed25519.Hibernate-CI.github.com' , ' hibernate.filemgmt.jboss.org' , ' hibernate-ci.frs.sourceforge.net' ]) {
178
+ dir(' .release/hibernate.org' ) {
179
+ checkout scmGit(branches : [[name : ' */production' ]], extensions : [], userRemoteConfigs : [[credentialsId : ' ed25519.Hibernate-CI.github.com' , url : ' https://github.com/hibernate/hibernate.org.git' ]])
180
+ sh " ../scripts/website-release.sh ${ env.SCRIPT_OPTIONS} ${ env.PROJECT} ${ env.VERSION_BASIS} "
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ }
187
+ stage(' GitHub release' ) {
188
+ steps {
189
+ script {
190
+ dir(' .release/scripts' ) {
191
+ checkout scmGit(branches : [[name : ' */main' ]], extensions : [], userRemoteConfigs : [[credentialsId : ' ed25519.Hibernate-CI.github.com' , url : ' https://github.com/hibernate/hibernate-release-scripts.git' ]])
192
+ }
193
+ withCredentials([string(credentialsId : ' Hibernate-CI.github.com' , variable : ' GITHUB_API_TOKEN' )]) {
194
+ sh " .release/scripts/github-release.sh ${ env.SCRIPT_OPTIONS} ${ env.PROJECT} ${ env.RELEASE_VERSION} "
195
+ }
196
+ }
197
+ }
198
+ }
199
+ }
200
+ post {
201
+ always {
202
+ configFileProvider([configFile(fileId : ' job-configuration.yaml' , variable : ' JOB_CONFIGURATION_FILE' )]) {
203
+ notifyBuildResult maintainers : (String ) readYaml(file : env. JOB_CONFIGURATION_FILE ). notification?. email?. recipients
204
+ }
205
+ }
206
+ }
207
+ }
0 commit comments