@@ -17,11 +17,10 @@ import org.hibernate.jenkins.pipeline.helpers.version.Version
1717// Global build configuration
1818env. PROJECT = " orm"
1919env. JIRA_KEY = " HHH"
20- def RELEASE_ON_PUSH = false // Set to `true` *only* on branches where you want a release on each push .
20+ def RELEASE_ON_SCHEDULE = false // Set to `true` *only* on branches where you want a scheduled release .
2121
2222print " INFO: env.PROJECT = ${ env.PROJECT} "
2323print " INFO: env.JIRA_KEY = ${ env.JIRA_KEY} "
24- print " INFO: RELEASE_ON_PUSH = ${ RELEASE_ON_PUSH} "
2524
2625// --------------------------------------------
2726// Build conditions
@@ -34,10 +33,17 @@ if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
3433}
3534
3635def manualRelease = currentBuild. getBuildCauses(). toString(). contains( ' UserIdCause' )
36+ def cronRelease = currentBuild. getBuildCauses(). toString(). contains( ' TimerTriggerCause' )
3737
3838// Only do automatic release on branches where we opted in
39- if ( ! manualRelease && ! RELEASE_ON_PUSH ) {
40- print " INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_PUSH in ci/release/Jenkinsfile"
39+ if ( ! manualRelease && ! cronRelease ) {
40+ print " INFO: Build skipped because automated releases on push are disabled on this branch."
41+ currentBuild. result = ' NOT_BUILT'
42+ return
43+ }
44+
45+ if ( ! manualRelease && cronRelease && ! RELEASE_ON_SCHEDULE ) {
46+ print " INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_SCHEDULE in ci/release/Jenkinsfile"
4147 currentBuild. result = ' NOT_BUILT'
4248 return
4349}
@@ -61,12 +67,15 @@ pipeline {
6167 agent {
6268 label ' Worker&&Containers'
6369 }
70+ triggers {
71+ // Run every week Sunday midnight
72+ cron(' 0 0 * * 0' )
73+ }
6474 tools {
6575 jdk ' OpenJDK 17 Latest'
6676 }
6777 options {
6878 buildDiscarder logRotator(daysToKeepStr : ' 30' , numToKeepStr : ' 10' )
69- rateLimitBuilds(throttle : [count : 1 , durationName : ' day' , userBoost : true ])
7079 disableConcurrentBuilds(abortPrevious : false )
7180 preserveStashes()
7281 }
@@ -130,7 +139,8 @@ pipeline {
130139 def secondLastCommitter = sh(script : ' git show -s --format=\' %an\' HEAD~1' , returnStdout : true )
131140 if (lastCommitter == ' Hibernate-CI' && secondLastCommitter == ' Hibernate-CI' ) {
132141 print " INFO: Automatic release skipped because last commits were for the previous release"
133- currentBuild. result = ' ABORTED'
142+ currentBuild. getRawBuild(). getExecutor(). interrupt(Result . NOT_BUILT )
143+ sleep(1 ) // Interrupt is not blocking and does not take effect immediately.
134144 return
135145 }
136146
@@ -154,10 +164,7 @@ pipeline {
154164
155165 env. RELEASE_VERSION = releaseVersion. toString()
156166 env. DEVELOPMENT_VERSION = developmentVersion. toString()
157-
158- if ( params. RELEASE_DRY_RUN ) {
159- env. SCRIPT_OPTIONS + = " -d"
160- }
167+ env. SCRIPT_OPTIONS = params. RELEASE_DRY_RUN ? " -d" : " "
161168
162169 // Determine version id to check if Jira version exists
163170 sh " .release/scripts/determine-jira-version-id.sh ${ env.JIRA_KEY} ${ releaseVersion.withoutFinalQualifier} "
@@ -206,7 +213,7 @@ pipeline {
206213 // https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html#account_setup
207214 usernamePassword(credentialsId : ' gradle-plugin-portal-api-key' , passwordVariable : ' GRADLE_PUBLISH_SECRET' , usernameVariable : ' GRADLE_PUBLISH_KEY' ),
208215 file(credentialsId : ' release.gpg.private-key' , variable : ' SIGNING_GPG_PRIVATE_KEY_PATH' ),
209- string(credentialsId : ' release.gpg.passphrase' , variable : ' SIGNING_GPG_PASSPHRASE' )
216+ string(credentialsId : ' release.gpg.passphrase' , variable : ' SIGNING_GPG_PASSPHRASE' ),
210217 gitUsernamePassword(credentialsId : ' username-and-token.Hibernate-CI.github.com' , gitToolName : ' Default' )
211218 ]) {
212219 sshagent([' ed25519.Hibernate-CI.github.com' , ' hibernate.filemgmt.jboss.org' , ' hibernate-ci.frs.sourceforge.net' ]) {
@@ -277,4 +284,4 @@ pipeline {
277284 }
278285 }
279286 }
280- }
287+ }
0 commit comments