Skip to content

Commit 9b6c263

Browse files
authored
chore: allow to differenciate JDKs to build depending on Jenkins release line (#2178)
1 parent 69569cb commit 9b6c263

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

Jenkinsfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ stage('Build') {
116116
}
117117

118118
if (!infra.isTrusted()) {
119+
// This list can be updated with the following command:
120+
// make show | jq -r '.target | keys[]' | sort
119121
def images = [
120122
'alpine_jdk17',
121123
'alpine_jdk21',

docker-bake.hcl

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Variables
2-
variable "jdks_to_build" {
2+
variable "jdks_to_build_for_lts" {
3+
default = [17, 21, 25]
4+
}
5+
6+
variable "jdks_to_build_for_weekly" {
37
default = [17, 21, 25]
48
}
59

@@ -99,7 +103,7 @@ variable "current_rhel" {
99103
## Targets
100104
target "alpine" {
101105
matrix = {
102-
jdk = jdks_to_build
106+
jdk = jdks_to_build()
103107
}
104108
name = "alpine_jdk${jdk}"
105109
dockerfile = "alpine/hotspot/Dockerfile"
@@ -119,7 +123,7 @@ target "alpine" {
119123

120124
target "debian" {
121125
matrix = {
122-
jdk = jdks_to_build
126+
jdk = jdks_to_build()
123127
variant = debian_variants
124128
}
125129
name = "${variant}_jdk${jdk}"
@@ -142,7 +146,7 @@ target "debian" {
142146

143147
target "rhel" {
144148
matrix = {
145-
jdk = jdks_to_build
149+
jdk = jdks_to_build()
146150
}
147151
name = "rhel_jdk${jdk}"
148152
dockerfile = "rhel/Dockerfile"
@@ -171,6 +175,21 @@ group "linux" {
171175
}
172176

173177
## Common functions
178+
# return true if JENKINS_VERSION is a Weekly (one sequence of digits with a trailing literal '.')
179+
function "is_jenkins_version_weekly" {
180+
# If JENKINS_VERSION has more than one sequence of digits with a trailing literal '.', this is LTS
181+
# 2.523 has only one sequence of digits with a trailing literal '.'
182+
# 2.516.1 has two sequences of digits with a trailing literal '.'
183+
params = []
184+
result = length(regexall("[0-9]+[.]", JENKINS_VERSION)) < 2 ? true : false
185+
}
186+
187+
# return the list of jdk to build depending on JENKINS_VERSION
188+
function "jdks_to_build" {
189+
params = []
190+
result = is_jenkins_version_weekly() ? jdks_to_build_for_weekly : jdks_to_build_for_lts
191+
}
192+
174193
# return a tag prefixed by the Jenkins version
175194
function "_tag_jenkins_version" {
176195
params = [tag]
@@ -197,13 +216,10 @@ function "tag_lts" {
197216

198217
# return WAR_URL if not empty, get.jenkins.io URL depending on JENKINS_VERSION release line otherwise
199218
function "war_url" {
200-
# If JENKINS_VERSION has more than one sequence of digits with a trailing literal '.', this is LTS
201-
# 2.523 has only one sequence of digits with a trailing literal '.'
202-
# 2.516.1 has two sequences of digits with a trailing literal '.'
203219
params = []
204220
result = (notequal(WAR_URL, "")
205221
? WAR_URL
206-
: (length(regexall("[0-9]+[.]", JENKINS_VERSION)) < 2
222+
: (is_jenkins_version_weekly()
207223
? "https://get.jenkins.io/war/${JENKINS_VERSION}/jenkins.war"
208224
: "https://get.jenkins.io/war-stable/${JENKINS_VERSION}/jenkins.war"))
209225
}

0 commit comments

Comments
 (0)