Skip to content

Commit

Permalink
Remove Java 11 images on weekly release line
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeurherve committed Jun 12, 2024
1 parent ab63f1f commit 97c732b
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 135 deletions.
11 changes: 9 additions & 2 deletions .ci/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ else
LATEST_WEEKLY="false"
fi

# Build all images including Java 11 if the version match latest LTS version
# TODO: remove when Java 11 is removed from LTS line
# See https://github.com/jenkinsci/docker/issues/1890
TARGET="linux"

if [[ "${JENKINS_VERSION}" == "${latest_lts_version}" ]]
then
LATEST_LTS="true"
TARGET="linux-lts-with-jdk11"
else
LATEST_LTS="false"
fi
Expand All @@ -84,7 +90,7 @@ fi

JENKINS_SHA="$(curl --disable --fail --silent --show-error --location "https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war.sha256")"
COMMIT_SHA=$(git rev-parse HEAD)
export COMMIT_SHA JENKINS_VERSION JENKINS_SHA LATEST_WEEKLY LATEST_LTS
export COMMIT_SHA JENKINS_VERSION JENKINS_SHA LATEST_WEEKLY LATEST_LTS TARGET

cat <<EOF
Using the following settings:
Expand All @@ -94,6 +100,7 @@ Using the following settings:
* COMMIT_SHA: ${COMMIT_SHA}
* LATEST_WEEKLY: ${LATEST_WEEKLY}
* LATEST_LTS: ${LATEST_LTS}
* TARGET: ${TARGET}
EOF

docker buildx bake --file docker-bake.hcl "${build_opts[@]}" linux
docker buildx bake --file docker-bake.hcl "${build_opts[@]}" "${TARGET}"
267 changes: 151 additions & 116 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,76 @@ properties(listOfProperties)

stage('Build') {
def builds = [:]
def windowsImageTypes = [
'windowsservercore-ltsc2019',
]
for (anImageType in windowsImageTypes) {
def imageType = anImageType
builds[imageType] = {
nodeWithTimeout('windows-2019') {
stage('Checkout') {
checkout scm
}

withEnv(["IMAGE_TYPE=${imageType}"]) {
if (!infra.isTrusted()) {
/* Outside of the trusted.ci environment, we're building and testing
* the Dockerfile in this repository, but not publishing to docker hub
*/
stage("Build ${imageType}") {
infra.withDockerCredentials {
powershell './make.ps1'
// Determine if the tag name (ie Jenkins version) correspond to a LTS (3 groups of digits)
// to use the appropriate bake target and set of images to build (including or not Java 11)
def isLTS
if (env.TAG_NAME && env.TAG_NAME =~ /^\d+\.\d+\.\d+$/) {
isLTS = true
target = 'linux-lts-with-jdk11'
} else {
isLTS = false
target = 'linux'
}
echo "= bake target: $target"
echo "= isLTS: $isLTS"

withEnv (["TARGET=${target}"]) {
def windowsImageTypes = [
'windowsservercore-ltsc2019',
]
for (anImageType in windowsImageTypes) {
def imageType = anImageType
builds[imageType] = {
nodeWithTimeout('windows-2019') {
stage('Checkout') {
checkout scm
}

withEnv(["IMAGE_TYPE=${imageType}"]) {
if (!infra.isTrusted()) {
/* Outside of the trusted.ci environment, we're building and testing
* the Dockerfile in this repository, but not publishing to docker hub
*/
stage("Build ${imageType}") {
infra.withDockerCredentials {
powershell './make.ps1'
}
}
}

stage("Test ${imageType}") {
infra.withDockerCredentials {
def windowsTestStatus = powershell(script: './make.ps1 test', returnStatus: true)
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml')
if (windowsTestStatus > 0) {
// If something bad happened let's clean up the docker images
error('Windows test stage failed.')
stage("Test ${imageType}") {
infra.withDockerCredentials {
def windowsTestStatus = powershell(script: './make.ps1 test', returnStatus: true)
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml')
if (windowsTestStatus > 0) {
// If something bad happened let's clean up the docker images
error('Windows test stage failed.')
}
}
}
}

// disable until we get the parallel changes merged in
// def branchName = "${env.BRANCH_NAME}"
// if (branchName ==~ 'master'){
// stage('Publish Experimental') {
// infra.withDockerCredentials {
// withEnv(['DOCKERHUB_ORGANISATION=jenkins4eval','DOCKERHUB_REPO=jenkins']) {
// powershell './make.ps1 publish'
// }
// }
// }
// }
} else {
// Only publish when a tag triggered the build
if (env.TAG_NAME) {
// Split to ensure any suffix is not taken in account (but allow suffix tags to trigger rebuilds)
jenkins_version = env.TAG_NAME.split('-')[0]
withEnv(["JENKINS_VERSION=${jenkins_version}"]) {
stage('Publish') {
infra.withDockerCredentials {
withEnv(['DOCKERHUB_ORGANISATION=jenkins','DOCKERHUB_REPO=jenkins']) {
powershell './make.ps1 publish'
// disable until we get the parallel changes merged in
// def branchName = "${env.BRANCH_NAME}"
// if (branchName ==~ 'master'){
// stage('Publish Experimental') {
// infra.withDockerCredentials {
// withEnv(['DOCKERHUB_ORGANISATION=jenkins4eval','DOCKERHUB_REPO=jenkins']) {
// powershell './make.ps1 publish'
// }
// }
// }
// }
} else {
// Only publish when a tag triggered the build
if (env.TAG_NAME) {
// Split to ensure any suffix is not taken in account (but allow suffix tags to trigger rebuilds)
jenkins_version = env.TAG_NAME.split('-')[0]
withEnv(["JENKINS_VERSION=${jenkins_version}"]) {
stage('Publish') {
infra.withDockerCredentials {
withEnv(['DOCKERHUB_ORGANISATION=jenkins','DOCKERHUB_REPO=jenkins']) {
powershell './make.ps1 publish'
}
}
}
}
Expand All @@ -76,10 +92,21 @@ stage('Build') {
}
}
}
}

if (!infra.isTrusted()) {
def images = [
if (!infra.isTrusted()) {
def images

def imagesWithoutJava11 = [
'alpine_jdk17',
'alpine_jdk21',
'debian_jdk17',
'debian_jdk21',
'debian_slim_jdk17',
'debian_slim_jdk21',
'rhel_ubi9_jdk17',
'rhel_ubi9_jdk21',
]
def imagesWithJava11 = [
'almalinux_jdk11',
'alpine_jdk11',
'alpine_jdk17',
Expand All @@ -93,96 +120,104 @@ stage('Build') {
'rhel_ubi8_jdk11',
'rhel_ubi9_jdk17',
'rhel_ubi9_jdk21',
]
for (i in images) {
def imageToBuild = i

builds[imageToBuild] = {
nodeWithTimeout('docker') {
deleteDir()
]
// Build all images including Java 11 if the version match a LTS versioning pattern
// TODO: remove when Java 11 is removed from LTS line
// See https://github.com/jenkinsci/docker/issues/1890
if (isLTS) {
images = imagesWithJava11
} else {
images = imagesWithoutJava11
}
for (i in images) {
def imageToBuild = i

stage('Checkout') {
checkout scm
}
builds[imageToBuild] = {
nodeWithTimeout('docker') {
deleteDir()

stage('Static analysis') {
sh 'make hadolint shellcheck'
}
stage('Checkout') {
checkout scm
}

/* Outside of the trusted.ci environment, we're building and testing
* the Dockerfile in this repository, but not publishing to docker hub
*/
stage("Build linux-${imageToBuild}") {
infra.withDockerCredentials {
sh "make build-${imageToBuild}"
stage('Static analysis') {
sh 'make hadolint shellcheck'
}
}

stage("Test linux-${imageToBuild}") {
sh "make prepare-test"
try {
/* Outside of the trusted.ci environment, we're building and testing
* the Dockerfile in this repository, but not publishing to docker hub
*/
stage("Build linux-${imageToBuild}") {
infra.withDockerCredentials {
sh "make test-${imageToBuild}"
sh "make build-${imageToBuild}"
}
}

stage("Test linux-${imageToBuild}") {
sh "make prepare-test"
try {
infra.withDockerCredentials {
sh "make test-${imageToBuild}"
}
} catch (err) {
error("${err.toString()}")
} finally {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/*.xml')
}
} catch (err) {
error("${err.toString()}")
} finally {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/*.xml')
}
}
}
}
}
builds['multiarch-build'] = {
nodeWithTimeout('docker') {
stage('Checkout') {
deleteDir()
checkout scm
}
builds['multiarch-build'] = {
nodeWithTimeout('docker') {
stage('Checkout') {
deleteDir()
checkout scm
}

// sanity check that proves all images build on declared platforms
stage('Multi arch build') {
infra.withDockerCredentials {
sh '''
docker buildx create --use
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx bake --file docker-bake.hcl linux
'''
// sanity check that proves all images build on declared platforms
stage('Multi arch build') {
infra.withDockerCredentials {
sh '''
docker buildx create --use
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx bake --file docker-bake.hcl "${TARGET}"
'''
}
}
}
}
}
} else {
// Only publish when a tag triggered the build
if (env.TAG_NAME) {
// Split to ensure any suffix is not taken in account (but allow suffix tags to trigger rebuilds)
jenkins_version = env.TAG_NAME.split('-')[0]
builds['linux'] = {
withEnv(["JENKINS_VERSION=${jenkins_version}"]) {
nodeWithTimeout('docker') {
stage('Checkout') {
checkout scm
}
} else {
// Only publish when a tag triggered the build
if (env.TAG_NAME) {
// Split to ensure any suffix is not taken in account (but allow suffix tags to trigger rebuilds)
jenkins_version = env.TAG_NAME.split('-')[0]
builds['linux'] = {
withEnv(["JENKINS_VERSION=${jenkins_version}"]) {
nodeWithTimeout('docker') {
stage('Checkout') {
checkout scm
}

stage('Publish') {
infra.withDockerCredentials {
sh '''
docker buildx create --use
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
make publish
'''
stage('Publish') {
infra.withDockerCredentials {
sh '''
docker buildx create --use
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
make publish
'''
}
}
}
}
}
}
}
}

parallel builds
parallel builds
}
}


void nodeWithTimeout(String label, def body) {
node(label) {
timeout(time: 60, unit: 'MINUTES') {
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ DISABLE_PARALLEL_TESTS ?= false
# default is "all test suites in the "tests/" directory
TEST_SUITES ?= $(CURDIR)/tests

# Set to linux-lts-with-jdk11 to build all images including Java 11 if the version match a LTS versioning pattern
# TODO: remove when Java 11 is removed from LTS line
# See https://github.com/jenkinsci/docker/issues/1890
TARGET ?= linux

##### Macros
## Check the presence of a CLI in the current PATH
check_cli = type "$(1)" >/dev/null 2>&1 || { echo "Error: command '$(1)' required but not found. Exiting." ; exit 1 ; }
Expand Down Expand Up @@ -53,7 +58,7 @@ build-%: check-reqs
@set -x; $(bake_base_cli) --set '*.platform=linux/$(ARCH)' '$*'

show:
@$(bake_base_cli) linux --print
@$(bake_base_cli) $(TARGET) --print

list: check-reqs
@set -x; make --silent show | jq -r '.target | path(.. | select(.platforms[] | contains("linux/$(ARCH)"))?) | add'
Expand Down
Loading

0 comments on commit 97c732b

Please sign in to comment.