Skip to content

[6.2] Backport "Use a script to release on Jira + avoid auto-release when there are no "releasable" commits" #10238

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 3 commits into from
May 28, 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
39 changes: 23 additions & 16 deletions ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pipeline {
)
}
stages {
stage('Release check') {
stage('Check') {
steps {
script {
print "INFO: params.RELEASE_VERSION = ${params.RELEASE_VERSION}"
Expand All @@ -116,13 +116,6 @@ pipeline {
def releaseVersion
def developmentVersion

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()
def isCiLastCommiter = lastCommitter == 'Hibernate-CI' && secondLastCommitter == 'Hibernate-CI'

echo "Last two commits were performed by '${lastCommitter}'/'${secondLastCommitter}'."
echo "Is 'Hibernate-CI' the last commiter: '${isCiLastCommiter}'."

if ( manualRelease ) {
echo "Release was requested manually"

Expand All @@ -140,10 +133,13 @@ pipeline {
else {
echo "Release was triggered automatically"

// Avoid doing an automatic release for commits from a release

if (isCiLastCommiter) {
print "INFO: Automatic release skipped because last commits were for the previous release"
// 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 Down Expand Up @@ -177,7 +173,7 @@ pipeline {
}
}
}
stage('Release prepare') {
stage('Prepare') {
steps {
script {
checkoutReleaseScripts()
Expand All @@ -203,7 +199,7 @@ pipeline {
}
}
}
stage('Publish release') {
stage('Publish') {
steps {
script {
checkoutReleaseScripts()
Expand Down Expand Up @@ -243,7 +239,18 @@ pipeline {
}
}
}
stage('Website release') {
stage('Release on Jira') {
steps {
script {
checkoutReleaseScripts()

withCredentials([string(credentialsId: 'release-webhook.hibernate.atlassian.net', variable: 'JIRA_WEBHOOK_SECRET')]) {
sh ".release/scripts/jira-release.sh ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION}"
}
}
}
}
stage('Update website') {
steps {
script {
checkoutReleaseScripts()
Expand All @@ -270,7 +277,7 @@ pipeline {
}
}
}
stage('GitHub release') {
stage('Create GitHub release') {
steps {
script {
checkoutReleaseScripts()
Expand Down
Loading