13
13
14
14
import org.hibernate.jenkins.pipeline.helpers.version.Version
15
15
16
- def checkoutReleaseScripts () {
17
- dir(' .release/scripts' ) {
18
- checkout scmGit(branches : [[name : ' */main' ]], extensions : [],
19
- userRemoteConfigs : [[credentialsId : ' ed25519.Hibernate-CI.github.com' ,
20
- url : ' https://github.com/hibernate/hibernate-release-scripts.git' ]])
21
- }
22
- }
16
+ // --------------------------------------------
17
+ // Global build configuration
18
+ env. PROJECT = " orm"
19
+ env. JIRA_KEY = " HHH"
20
+ def RELEASE_ON_PUSH = false // Set to `true` *only* on branches where you want a release on each push.
21
+
22
+ // --------------------------------------------
23
+ // Build conditions
23
24
24
25
// Avoid running the pipeline on branch indexing
25
26
if (currentBuild. getBuildCauses(). toString(). contains(' BranchIndexingCause' )) {
@@ -28,8 +29,28 @@ if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
28
29
return
29
30
}
30
31
31
- env. PROJECT = " orm"
32
- env. JIRA_KEY = " HHH"
32
+ def manualRelease = currentBuild. getBuildCauses(). toString(). contains( ' UserIdCause' )
33
+
34
+ // Only do automatic release on branches where we opted in
35
+ if ( ! manualRelease && ! RELEASE_ON_PUSH ) {
36
+ print " INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_PUSH in ci/release/Jenkinsfile"
37
+ currentBuild. result = ' NOT_BUILT'
38
+ return
39
+ }
40
+
41
+ // --------------------------------------------
42
+ // Reusable methods
43
+
44
+ def checkoutReleaseScripts () {
45
+ dir(' .release/scripts' ) {
46
+ checkout scmGit(branches : [[name : ' */main' ]], extensions : [],
47
+ userRemoteConfigs : [[credentialsId : ' ed25519.Hibernate-CI.github.com' ,
48
+ url : ' https://github.com/hibernate/hibernate-release-scripts.git' ]])
49
+ }
50
+ }
51
+
52
+ // --------------------------------------------
53
+ // Pipeline
33
54
34
55
pipeline {
35
56
agent {
@@ -69,8 +90,6 @@ pipeline {
69
90
script {
70
91
checkoutReleaseScripts()
71
92
72
- def manualRelease = currentBuild. getBuildCauses(). toString(). contains( ' UserIdCause' )
73
-
74
93
def currentVersion = Version . parseDevelopmentVersion( sh(
75
94
script : " .release/scripts/determine-current-version.sh ${ env.PROJECT} " ,
76
95
returnStdout : true
@@ -95,13 +114,6 @@ pipeline {
95
114
else {
96
115
echo " Release was triggered automatically"
97
116
98
- // Avoid doing an automatic release on a non-maintenance branch
99
- if ( ! ( env. BRANCH_NAME ==~ / ^\d +\.\d +$/ ) ) {
100
- print " INFO: Automatic release skipped because the branch name doesn't follow pattern /^\\ d+\\ .\\ d+\$ /"
101
- currentBuild. result = ' ABORTED'
102
- return
103
- }
104
-
105
117
// Avoid doing an automatic release for commits from a release
106
118
def lastCommitter = sh(script : ' git show -s --format=\' %an\' ' , returnStdout : true )
107
119
def secondLastCommitter = sh(script : ' git show -s --format=\' %an\' HEAD~1' , returnStdout : true )
0 commit comments