Skip to content

Commit 7fc211f

Browse files
committed
chore: allow to differenciate JDKs to build depending on Jenkins release line (#2178)
1 parent 61440de commit 7fc211f

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
@@ -113,6 +113,8 @@ stage('Build') {
113113
}
114114

115115
if (!infra.isTrusted()) {
116+
// This list can be updated with the following command:
117+
// make show | jq -r '.target | keys[]' | sort
116118
def images = [
117119
'alpine_jdk17',
118120
'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]
4+
}
5+
6+
variable "jdks_to_build_for_weekly" {
37
default = [17, 21]
48
}
59

@@ -94,7 +98,7 @@ variable "current_rhel" {
9498
## Targets
9599
target "alpine" {
96100
matrix = {
97-
jdk = jdks_to_build
101+
jdk = jdks_to_build()
98102
}
99103
name = "alpine_jdk${jdk}"
100104
dockerfile = "alpine/hotspot/Dockerfile"
@@ -114,7 +118,7 @@ target "alpine" {
114118

115119
target "debian" {
116120
matrix = {
117-
jdk = jdks_to_build
121+
jdk = jdks_to_build()
118122
variant = debian_variants
119123
}
120124
name = "${variant}_jdk${jdk}"
@@ -137,7 +141,7 @@ target "debian" {
137141

138142
target "rhel" {
139143
matrix = {
140-
jdk = jdks_to_build
144+
jdk = jdks_to_build()
141145
}
142146
name = "rhel_jdk${jdk}"
143147
dockerfile = "rhel/Dockerfile"
@@ -166,6 +170,21 @@ group "linux" {
166170
}
167171

168172
## Common functions
173+
# return true if JENKINS_VERSION is a Weekly (one sequence of digits with a trailing literal '.')
174+
function "is_jenkins_version_weekly" {
175+
# If JENKINS_VERSION has more than one sequence of digits with a trailing literal '.', this is LTS
176+
# 2.523 has only one sequence of digits with a trailing literal '.'
177+
# 2.516.1 has two sequences of digits with a trailing literal '.'
178+
params = []
179+
result = length(regexall("[0-9]+[.]", JENKINS_VERSION)) < 2 ? true : false
180+
}
181+
182+
# return the list of jdk to build depending on JENKINS_VERSION
183+
function "jdks_to_build" {
184+
params = []
185+
result = is_jenkins_version_weekly() ? jdks_to_build_for_weekly : jdks_to_build_for_lts
186+
}
187+
169188
# return a tag prefixed by the Jenkins version
170189
function "_tag_jenkins_version" {
171190
params = [tag]
@@ -192,13 +211,10 @@ function "tag_lts" {
192211

193212
# return WAR_URL if not empty, get.jenkins.io URL depending on JENKINS_VERSION release line otherwise
194213
function "war_url" {
195-
# If JENKINS_VERSION has more than one sequence of digits with a trailing literal '.', this is LTS
196-
# 2.523 has only one sequence of digits with a trailing literal '.'
197-
# 2.516.1 has two sequences of digits with a trailing literal '.'
198214
params = []
199215
result = (notequal(WAR_URL, "")
200216
? WAR_URL
201-
: (length(regexall("[0-9]+[.]", JENKINS_VERSION)) < 2
217+
: (is_jenkins_version_weekly()
202218
? "https://get.jenkins.io/war/${JENKINS_VERSION}/jenkins.war"
203219
: "https://get.jenkins.io/war-stable/${JENKINS_VERSION}/jenkins.war"))
204220
}

0 commit comments

Comments
 (0)