Skip to content

Release job alignment on Hibernate ORM + improvements #2319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 76 additions & 35 deletions ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#! /usr/bin/groovy
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/

/*
Expand All @@ -17,11 +15,10 @@ import org.hibernate.jenkins.pipeline.helpers.version.Version
// Global build configuration
env.PROJECT = "reactive"
env.JIRA_KEY = "HREACT"
def RELEASE_ON_PUSH = false // Set to `true` *only* on branches where you want a release on each push.
def RELEASE_ON_SCHEDULE = false // Set to `true` *only* on branches where you want a scheduled release.

print "INFO: env.PROJECT = ${env.PROJECT}"
print "INFO: env.JIRA_KEY = ${env.JIRA_KEY}"
print "INFO: RELEASE_ON_PUSH = ${RELEASE_ON_PUSH}"

// --------------------------------------------
// Build conditions
Expand All @@ -34,10 +31,17 @@ if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
}

def manualRelease = currentBuild.getBuildCauses().toString().contains( 'UserIdCause' )
def cronRelease = currentBuild.getBuildCauses().toString().contains( 'TimerTriggerCause' )

// Only do automatic release on branches where we opted in
if ( !manualRelease && !RELEASE_ON_PUSH ) {
print "INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_PUSH in ci/release/Jenkinsfile"
if ( !manualRelease && !cronRelease ) {
print "INFO: Build skipped because automated releases on push are disabled on this branch."
currentBuild.result = 'NOT_BUILT'
return
}

if ( !manualRelease && cronRelease && !RELEASE_ON_SCHEDULE ) {
print "INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_SCHEDULE in ci/release/Jenkinsfile"
currentBuild.result = 'NOT_BUILT'
return
}
Expand All @@ -53,19 +57,23 @@ def checkoutReleaseScripts() {
}
}


// --------------------------------------------
// Pipeline

pipeline {
agent {
label 'Release'
}
triggers {
// Run every week Sunday 1 AM
cron('0 1 * * 0')
}
tools {
jdk 'OpenJDK 17 Latest'
}
options {
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
rateLimitBuilds(throttle: [count: 1, durationName: 'day', userBoost: true])
disableConcurrentBuilds(abortPrevious: false)
preserveStashes()
}
Expand All @@ -89,9 +97,13 @@ pipeline {
)
}
stages {
stage('Release check') {
stage('Check') {
steps {
script {
print "INFO: params.RELEASE_VERSION = ${params.RELEASE_VERSION}"
print "INFO: params.DEVELOPMENT_VERSION = ${params.DEVELOPMENT_VERSION}"
print "INFO: params.RELEASE_DRY_RUN? = ${params.RELEASE_DRY_RUN}"

checkoutReleaseScripts()

def currentVersion = Version.parseDevelopmentVersion( sh(
Expand All @@ -107,7 +119,9 @@ pipeline {
echo "Release was requested manually"

if ( !params.RELEASE_VERSION ) {
throw new IllegalArgumentException( 'Missing value for parameter RELEASE_VERSION. This parameter must be set explicitly to prevent mistakes.' )
throw new IllegalArgumentException(
'Missing value for parameter RELEASE_VERSION. This parameter must be set explicitly to prevent mistakes.'
)
}
releaseVersion = Version.parseReleaseVersion( params.RELEASE_VERSION )

Expand All @@ -118,14 +132,15 @@ pipeline {
else {
echo "Release was triggered automatically"

// Avoid doing an automatic release for commits from a release
def lastCommitter = sh(script: 'git show -s --format=\'%an\'', returnStdout: true).trim()
def secondLastCommitter = sh(script: 'git show -s --format=\'%an\' HEAD~1', returnStdout: true).trim()
echo "Last two commits were performed by '${lastCommitter}'/'${secondLastCommitter}'."

if (lastCommitter == 'Hibernate-CI' && secondLastCommitter == 'Hibernate-CI') {
print "INFO: Automatic release skipped because last commits were for the previous release"
currentBuild.result = 'ABORTED'
// Avoid doing an automatic release if there are no "releasable" commits since the last release (see release scripts for determination)
def releasableCommitCount = sh(
script: ".release/scripts/count-releasable-commits.sh ${env.PROJECT}",
returnStdout: true
).trim().toInteger()
if ( releasableCommitCount <= 0 ) {
print "INFO: Automatic release skipped because no releasable commits were pushed since the previous release"
currentBuild.getRawBuild().getExecutor().interrupt(Result.NOT_BUILT)
sleep(1) // Interrupt is not blocking and does not take effect immediately.
return
}

Expand All @@ -149,17 +164,12 @@ pipeline {

env.RELEASE_VERSION = releaseVersion.toString()
env.DEVELOPMENT_VERSION = developmentVersion.toString()
// Dry run is not supported at the moment
env.SCRIPT_OPTIONS = params.RELEASE_DRY_RUN ? "-d" : ""
env.SCRIPT_OPTIONS = params.RELEASE_DRY_RUN ? "-d" : ""
env.JRELEASER_DRY_RUN = params.RELEASE_DRY_RUN

// Determine version id to check if Jira version exists
// This step doesn't work for Hibernate Reactive (the project has been created with a different type on JIRA)
// sh ".release/scripts/determine-jira-version-id.sh ${env.JIRA_KEY} ${releaseVersion.withoutFinalQualifier}"
}
}
}
stage('Release prepare') {
stage('Prepare') {
steps {
script {
checkoutReleaseScripts()
Expand All @@ -168,13 +178,13 @@ pipeline {
configFile(fileId: 'release.config.ssh', targetLocation: "${env.HOME}/.ssh/config"),
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: "${env.HOME}/.ssh/known_hosts")
]) {

sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
// set release version
// update changelog from JIRA
// tags the version
// changes the version to the provided development version
withEnv([
"DISABLE_REMOTE_GRADLE_CACHE=true",
// Increase the amount of memory for this part since asciidoctor doc rendering consumes a lot of metaspace
"GRADLE_OPTS=-Dorg.gradle.jvmargs='-Dlog4j2.disableJmx -Xmx4g -XX:MaxMetaspaceSize=768m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8'"
]) {
Expand All @@ -185,7 +195,7 @@ pipeline {
}
}
}
stage('Publish release') {
stage('Publish') {
steps {
script {
checkoutReleaseScripts()
Expand All @@ -195,16 +205,47 @@ pipeline {
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: "${env.HOME}/.ssh/known_hosts")
]) {
withCredentials([
usernamePassword(credentialsId: 'central.sonatype.com', passwordVariable: 'JRELEASER_MAVENCENTRAL_TOKEN', usernameVariable: 'JRELEASER_MAVENCENTRAL_USERNAME'),
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default'),
file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')
usernamePassword(credentialsId: 'central.sonatype.com', passwordVariable: 'JRELEASER_MAVENCENTRAL_TOKEN', usernameVariable: 'JRELEASER_MAVENCENTRAL_USERNAME'),
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default'),
file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')
]) {
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
// performs documentation upload and Sonatype release
// push to github
sh ".release/scripts/publish.sh -j ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
withEnv([
"DISABLE_REMOTE_GRADLE_CACHE=true"
]) {
sh ".release/scripts/publish.sh -j ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
}
}
}
}
}
}
}
stage('Update website') {
steps {
script {
checkoutReleaseScripts()

configFileProvider([
configFile(fileId: 'release.config.ssh', targetLocation: "${env.HOME}/.ssh/config"),
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: "${env.HOME}/.ssh/known_hosts")
]) {
withCredentials([
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default')
]) {
sshagent( ['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net'] ) {
dir( '.release/hibernate.org' ) {
checkout scmGit(
branches: [[name: '*/production']],
extensions: [],
userRemoteConfigs: [[credentialsId: 'ed25519.Hibernate-CI.github.com', url: 'https://github.com/hibernate/hibernate.org.git']]
)
sh "../scripts/website-release.sh ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION}"
}
}
}
}
Expand Down
Loading