Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ def parallelStages = [failFast: false]
'windowsservercore-ltsc2022'
].each { imageType ->
parallelStages[imageType] = {
withEnv(["IMAGE_TYPE=${imageType}", "REGISTRY_ORG=${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}"]) {
withEnv([
"IMAGE_TYPE=${imageType}",
"REGISTRY_ORG=${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}",
// Set to "true" to enable experimental image(s) publication
"PUBLISH_EXPERIMENTAL=false"
]) {
int retryCounter = 0
retry(count: 2, conditions: [agent(), nonresumable()]) {
// Use local variable to manage concurrency and increment BEFORE spinning up any agent
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ prepare-test: bats check-reqs
publish:
@set -x; $(bake_base_cli) linux --push

# Strip experimental prefix if present
strip_experimental = $(patsubst experimental-jlink_%,%,$(1))

## Define bats options based on environment
# common flags for all tests
bats_flags := ""
Expand All @@ -105,9 +108,9 @@ test-%: prepare-test
# Each type of image ("agent" or "inbound-agent") has its own tests suite
ifeq ($(CI), true)
# Execute the test harness and write result to a TAP file
IMAGE=$* bats/bin/bats $(CURDIR)/tests/tests_$(shell echo $* | cut -d "_" -f 1).bats $(bats_flags) --formatter junit | tee target/junit-results-$*.xml
IMAGE=$(call strip_experimental,$*) bats/bin/bats $(CURDIR)/tests/tests_$(shell echo $(call strip_experimental,$*) | cut -d "_" -f 1).bats $(bats_flags) --formatter junit | tee target/junit-results-$*.xml
else
IMAGE=$* bats/bin/bats $(CURDIR)/tests/tests_$(shell echo $* | cut -d "_" -f 1).bats $(bats_flags)
IMAGE=$(call strip_experimental,$*) bats/bin/bats $(CURDIR)/tests/tests_$(shell echo $(call strip_experimental,$*) | cut -d "_" -f 1).bats $(bats_flags)
endif

test: prepare-test
Expand Down
5 changes: 4 additions & 1 deletion alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ RUN apk add --no-cache \

ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}"

ARG EXPERIMENTAL_JLINK=false
RUN java_major_version="$(jlink --version 2>&1 | cut -c1-2)"; \
if [[ "${TARGETPLATFORM}" == "linux/arm/v7" || "${java_major_version}" == 25 ]]; then \
if test "${EXPERIMENTAL_JLINK}" = "false" && [ "${TARGETPLATFORM}" = "linux/arm/v7" ] || [ "${java_major_version}" = "25" ]; then \
# It is acceptable to have a larger image in arm/v7 (arm 32 bits) environment
# because jlink fails with the error "jmods: Value too large for defined data type" error.
# For JDK25, we need to have a proper test and validation process first cf https://github.com/jenkinsci/docker-agents/issues/1124)
Expand All @@ -52,6 +53,8 @@ RUN java_major_version="$(jlink --version 2>&1 | cut -c1-2)"; \
case "$(jlink --version 2>&1 | cut -c1-2)" in \
"17") options="--compress=2 --add-modules ALL-MODULE-PATH" ;; \
"21") options="--compress=zip-6 --add-modules ALL-MODULE-PATH" ;; \
# Experimental
"25") options="--compress=zip-6 --add-modules java.base,java.logging,java.xml,java.se";; \
*) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \
esac; \
jlink \
Expand Down
5 changes: 4 additions & 1 deletion debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}"
# Generate smaller java runtime without unneeded files
# for now we include the full module path to maintain compatibility
# while still saving space (approx 200mb from the full distribution)
ARG EXPERIMENTAL_JLINK=false
RUN java_major_version="$(jlink --version 2>&1 | cut -c1-2)"; \
if [[ "${TARGETPLATFORM}" == "linux/arm/v7" || "${java_major_version}" == 25 ]]; then \
if test "${EXPERIMENTAL_JLINK}" = "false" && [ "${TARGETPLATFORM}" = "linux/arm/v7" ] || [ "${java_major_version}" = "25" ]; then \
# It is acceptable to have a larger image in arm/v7 (arm 32 bits) environment
# because jlink fails with the error "jmods: Value too large for defined data type" error.
# For JDK25, we need to have a proper test and validation process first cf https://github.com/jenkinsci/docker-agents/issues/1124)
Expand All @@ -56,6 +57,8 @@ RUN java_major_version="$(jlink --version 2>&1 | cut -c1-2)"; \
case "$(jlink --version 2>&1 | cut -c1-2)" in \
"17") options="--compress=2 --add-modules ALL-MODULE-PATH" ;; \
"21") options="--compress=zip-6 --add-modules ALL-MODULE-PATH" ;; \
# Experimental
"25") options="--compress=zip-6 --add-modules java.base,java.logging,java.xml,java.se";; \
*) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \
esac; \
jlink \
Expand Down
74 changes: 63 additions & 11 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ variable "jdks_in_preview" {
default = []
}

# List of inbound agent target(s) to use as base of experimental images.
# Default to inbound-agent image as it makes more sense to test that than the base agent one.
# Note: omit "inbound-agent_" from the target you chose from `make list`
variable "experimental_jlink_targets" {
default = ["debian_jdk25"]
}

# Set to "true" to enable experimental image(s) tag publication
variable "PUBLISH_EXPERIMENTAL" {
default = "false"
}

variable "JAVA17_VERSION" {
default = "17.0.17_10"
}
Expand Down Expand Up @@ -95,13 +107,12 @@ target "alpine" {
jdk = jdks_to_build
}
name = "${type}_alpine_jdk${jdk}"
inherits = ["_common_args_jdk${jdk}"]
target = type
dockerfile = "alpine/Dockerfile"
context = "."
args = {
ALPINE_TAG = ALPINE_FULL_TAG
VERSION = REMOTING_VERSION
JAVA_VERSION = "${javaversion(jdk)}"
}
tags = concat(linux_tags(type, jdk, "alpine"), linux_tags(type, jdk, "alpine${ALPINE_SHORT_TAG}"))
platforms = alpine_platforms(jdk)
Expand All @@ -113,13 +124,12 @@ target "debian" {
jdk = jdks_to_build
}
name = "${type}_debian_jdk${jdk}"
inherits = ["_common_args_jdk${jdk}"]
target = type
dockerfile = "debian/Dockerfile"
context = "."
args = {
VERSION = REMOTING_VERSION
DEBIAN_RELEASE = DEBIAN_RELEASE
JAVA_VERSION = "${javaversion(jdk)}"
}
tags = linux_tags(type, jdk, "debian")
platforms = debian_platforms(jdk)
Expand All @@ -131,13 +141,12 @@ target "rhel_ubi9" {
jdk = jdks_to_build
}
name = "${type}_rhel_ubi9_jdk${jdk}"
inherits = ["_common_args_jdk${jdk}"]
target = type
dockerfile = "rhel/ubi9/Dockerfile"
context = "."
args = {
UBI9_TAG = UBI9_TAG
VERSION = REMOTING_VERSION
JAVA_VERSION = "${javaversion(jdk)}"
}
tags = linux_tags(type, jdk, "rhel-ubi9")
platforms = rhel_ubi9_platforms(jdk)
Expand All @@ -150,13 +159,12 @@ target "nanoserver" {
windows_version = windowsversions("nanoserver")
}
name = "${type}_nanoserver-${windows_version}_jdk${jdk}"
inherits = ["_common_args_jdk${jdk}"]
dockerfile = "windows/nanoserver/Dockerfile"
context = "."
args = {
JAVA_HOME = "C:/openjdk-${jdk}"
JAVA_VERSION = "${replace(javaversion(jdk), "_", "+")}"
TOOLS_WINDOWS_VERSION = "${toolsversion(windows_version)}"
VERSION = REMOTING_VERSION
WINDOWS_VERSION_TAG = windows_version
}
target = type
Expand All @@ -171,26 +179,64 @@ target "windowsservercore" {
windows_version = windowsversions("windowsservercore")
}
name = "${type}_windowsservercore-${windows_version}_jdk${jdk}"
inherits = ["_common_args_jdk${jdk}"]
dockerfile = "windows/windowsservercore/Dockerfile"
context = "."
args = {
JAVA_HOME = "C:/openjdk-${jdk}"
JAVA_VERSION = "${replace(javaversion(jdk), "_", "+")}"
TOOLS_WINDOWS_VERSION = "${toolsversion(windows_version)}"
VERSION = REMOTING_VERSION
WINDOWS_VERSION_TAG = windows_version
}
target = type
tags = windows_tags(type, jdk, "windowsservercore-${windows_version}")
platforms = ["windows/amd64"]
}

## Experimental targets
target "experimental_jlink" {
matrix = {
bake_target = experimental_jlink_targets
}
name = "inbound-agent_${bake_target}_experimental-jlink"
inherits = ["inbound-agent_${bake_target}"]
args = {
EXPERIMENTAL_JLINK = "true"
}
labels = {
"org.opencontainers.image.title" = "Jenkins experimental ${bake_target} image using jlink"
}
# Assuming only experimenting on inbound-agent targets for now, can be revised if needed.
tags = ["${REGISTRY}/${orgrepo("inbound-agent")}:${REMOTING_VERSION}-${BUILD_NUMBER}-${bake_target}-experimental-jlink-not-prod-ready"]
# Output as image only if PUBLISH_EXPERIMENTAL is set to "true"
# Ref: https://docs.docker.com/build/bake/reference/#targetoutput
output = equal(PUBLISH_EXPERIMENTAL, "true") ? ["type=image"] : ["type=cacheonly"]
}

## Internal targets
target "_base" {
args = {
VERSION = REMOTING_VERSION
}
}

target "_common_args" {
inherits = ["_base"]
matrix = {
jdk = jdks_to_build
}
name = "_common_args_jdk${jdk}"
args = {
JAVA_VERSION = "${replace(javaversion(jdk), "_", "+")}"
}
}

## Groups
group "linux" {
targets = [
"alpine",
"debian",
"rhel_ubi9"
"rhel_ubi9",
"experimental"
]
}

Expand Down Expand Up @@ -228,6 +274,12 @@ group "linux-ppc64le" {
]
}

## Experimental groups
group "experimental" {
targets = [
"experimental_jlink"
]
}

## Common functions
# Return the registry organization and repository depending on the agent type
Expand Down
5 changes: 4 additions & 1 deletion rhel/ubi9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}"
# Generate smaller java runtime without unneeded files
# for now we include the full module path to maintain compatibility
# while still saving space (approx 200mb from the full distribution)
ARG EXPERIMENTAL_JLINK=false
RUN java_major_version="$(jlink --version 2>&1 | cut -c1-2)"; \
if [[ "${TARGETPLATFORM}" == "linux/arm/v7" || "${java_major_version}" == 25 ]]; then \
if test "${EXPERIMENTAL_JLINK}" = "false" && [ "${TARGETPLATFORM}" = "linux/arm/v7" ] || [ "${java_major_version}" = "25" ]; then \
# It is acceptable to have a larger image in arm/v7 (arm 32 bits) environment
# because jlink fails with the error "jmods: Value too large for defined data type" error.
# For JDK25, we need to have a proper test and validation process first cf https://github.com/jenkinsci/docker-agents/issues/1124)
Expand All @@ -34,6 +35,8 @@ RUN java_major_version="$(jlink --version 2>&1 | cut -c1-2)"; \
case "$(jlink --version 2>&1 | cut -c1-2)" in \
"17") options="--compress=2 --add-modules ALL-MODULE-PATH" ;; \
"21") options="--compress=zip-6 --add-modules ALL-MODULE-PATH" ;; \
# Experimental
"25") options="--compress=zip-6 --add-modules java.base,java.logging,java.xml,java.se";; \
*) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \
esac; \
jlink \
Expand Down
1 change: 1 addition & 0 deletions tests/golden/expected_tags_linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ docker.io/jenkins/agent:trixie
docker.io/jenkins/agent:trixie-jdk17
docker.io/jenkins/agent:trixie-jdk21
docker.io/jenkins/agent:trixie-jdk25
docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-debian_jdk25-experimental-jlink-not-prod-ready
docker.io/jenkins/inbound-agent:alpine
docker.io/jenkins/inbound-agent:alpine-jdk17
docker.io/jenkins/inbound-agent:alpine-jdk21
Expand Down
1 change: 1 addition & 0 deletions tests/golden/expected_tags_linux_on_tag.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-alpine3.23
docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-alpine3.23-jdk17
docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-alpine3.23-jdk21
docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-alpine3.23-jdk25
docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-debian_jdk25-experimental-jlink-not-prod-ready
docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-jdk17
docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-jdk21
docker.io/jenkins/inbound-agent:3355.v388858a_47b_33-1-jdk25
Expand Down