From a1a509ee4fdc31d7e95521f6dc691abb19e1ff9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Sat, 8 Jul 2023 19:14:30 +0200 Subject: [PATCH] adapt Jenkinsfile, windows stage, compared to docker-agent before recent refactoring --- Jenkinsfile | 200 ++++++++++------- alpine/Dockerfile | 4 +- build-windows.yaml | 8 +- build.ps1 | 61 +++--- debian/Dockerfile | 4 +- docker-bake.hcl | 24 +-- make.ps1 | 12 +- tests/inboundAgent.Tests.ps1 | 4 +- tests/tests.bats | 2 +- .../updatecli.d/jenkins-agent-parent.yaml | 204 ------------------ windows/nanoserver-1809/Dockerfile | 6 +- windows/windowsservercore-ltsc2019/Dockerfile | 6 +- 12 files changed, 194 insertions(+), 341 deletions(-) delete mode 100644 updatecli/updatecli.d/jenkins-agent-parent.yaml diff --git a/Jenkinsfile b/Jenkinsfile index 6bff728f..880ab5aa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,94 +3,144 @@ pipeline { options { buildDiscarder(logRotator(daysToKeepStr: '10')) + timestamps() } stages { - stage('docker-agent') { - failFast true - matrix { - axes { - axis { - name 'AGENT_TYPE' - values 'linux', 'windows-2019' + stage('Build') { + parallel { + stage('Windows') { + agent { + label "docker-windows" } - } - stages { - stage('Main') { - agent { - label env.AGENT_TYPE - } - options { - timeout(time: 30, unit: 'MINUTES') - } - environment { - DOCKERHUB_ORGANISATION = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}" - } - stages { - stage('Prepare Docker') { - when { - environment name: 'AGENT_TYPE', value: 'linux' - } - steps { - sh ''' - docker buildx create --use - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - ''' - } + options { + timeout(time: 60, unit: 'MINUTES') + } + environment { + DOCKERHUB_ORGANISATION = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}" + } + stages { + stage('Build and Test') { + // This stage is the "CI" and should be run on all code changes triggered by a code change + when { + not { buildingTag() } } - stage('Build and Test') { - // This stage is the "CI" and should be run on all code changes triggered by a code change - when { - not { buildingTag() } - } - steps { - script { - if(isUnix()) { - sh './build.sh' - sh './build.sh test' - // If the tests are passing for Linux AMD64, then we can build all the CPU architectures - sh 'docker buildx bake --file docker-bake.hcl linux' - } else { - powershell "& ./build.ps1 test" - } - } - } - post { - always { - junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml') - } - } + steps { + // script { + // def parallelBuilds = [:] + // def images = ['jdk11-windowsservercore-ltsc2019', 'jdk11-nanoserver-1809', 'jdk17-windowsservercore-ltsc2019', 'jdk17-nanoserver-1809'] + // for (unboundImage in images) { + // def image = unboundImage // Bind variable before the closure + // // Prepare a map of the steps to run in parallel + // parallelBuilds[image] = { + // // Allocate a node for each image to avoid filling disk + // node('docker-windows') { + // checkout scm + // powershell '& ./make.ps1 -Build ' + image + ' test' + // junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml') + // } + // } + // } + // // Peform the parallel execution + // parallel parallelBuilds + // } + powershell '& ./build.ps1 test' } - stage('Deploy to DockerHub') { - // This stage is the "CD" and should only be run when a tag triggered the build - when { - buildingTag() + post { + always { + junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml') } - steps { - script { - def tagItems = env.TAG_NAME.split('-') - if(tagItems.length == 2) { - def remotingVersion = tagItems[0] - def buildNumber = tagItems[1] - // This function is defined in the jenkins-infra/pipeline-library - infra.withDockerCredentials { - if (isUnix()) { - sh """ - docker buildx create --use - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - ./build.sh -r ${remotingVersion} -b ${buildNumber} -d publish - """ - } else { - powershell "& ./build.ps1 -PushVersions -RemotingVersion $remotingVersion -BuildNumber $buildNumber -DisableEnvProps publish" - } - } - } + } + } + stage('Deploy to DockerHub') { + // This stage is the "CD" and should only be run when a tag triggered the build + when { + buildingTag() + } + steps { + script { + // // This function is defined in the jenkins-infra/pipeline-library + // infra.withDockerCredentials { + // powershell '& ./make.ps1 -PushVersions -VersionTag $env:TAG_NAME publish' + // } + + // // Directly from docker-agent + // def tagItems = env.TAG_NAME.split('-') + // if(tagItems.length == 2) { + // def dockerAgentVersion = tagItems[0] + // def buildNumber = tagItems[1] + // // This function is defined in the jenkins-infra/pipeline-library + // infra.withDockerCredentials { + // powershell "& ./build.ps1 -PushVersions -DockerAgentVersion $dockerAgentVersion -BuildNumber $buildNumber -DisableEnvProps publish" + // } + // } + // debug + echo "=== env.TAG_NAME: ${env:TAG_NAME}" + infra.withDockerCredentials { + // TODO: check if this function has the same beahvior in build.ps1 vs make.ps1 + powershell '& ./build.ps1 -PushVersions -VersionTag $env:TAG_NAME publish' } } } } } } + // stage('Linux') { + // agent { + // label "docker&&linux" + // } + // options { + // timeout(time: 30, unit: 'MINUTES') + // } + // environment { + // JENKINS_REPO = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}/inbound-agent" + // } + // stages { + // stage('Prepare Docker') { + // steps { + // sh ''' + // docker buildx create --use + // docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + // ''' + // } + // } + // stage('Build and Test') { + // // This stage is the "CI" and should be run on all code changes triggered by a code change + // when { + // not { buildingTag() } + // } + // steps { + // sh 'make build' + // sh 'make test' + // // If the tests are passing for Linux AMD64, then we can build all the CPU architectures + // sh 'docker buildx bake --file docker-bake.hcl linux' + // } + // post { + // always { + // junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/*.xml') + // } + // } + // } + // stage('Deploy to DockerHub') { + // // This stage is the "CD" and should only be run when a tag triggered the build + // when { + // buildingTag() + // } + // steps { + // script { + // // This function is defined in the jenkins-infra/pipeline-library + // infra.withDockerCredentials { + // sh ''' + // export IMAGE_TAG="${TAG_NAME}" + // export ON_TAG=true + // docker buildx bake --push --file docker-bake.hcl linux + // ''' + // } + // } + // } + // } + // } + // } } } } diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 3450484f..3745d2da 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -21,11 +21,11 @@ # THE SOFTWARE. #TODO(oleg_nenashev): Does it also need an update? -ARG version=3131.vf2b_b_798b_ce99-2 +ARG VERSION=3131.vf2b_b_798b_ce99-2 ARG JAVA_MAJOR_VERSION=17 FROM jenkins/agent:"${version}"-alpine-jdk"${JAVA_MAJOR_VERSION}" -ARG version=3131.vf2b_b_798b_ce99-2 +ARG VERSION=3131.vf2b_b_798b_ce99-2 LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols" Vendor="Jenkins project" Version="$version" ARG user=jenkins diff --git a/build-windows.yaml b/build-windows.yaml index 75847993..af06a57f 100644 --- a/build-windows.yaml +++ b/build-windows.yaml @@ -6,7 +6,7 @@ services: args: JAVA_HOME: "C:/openjdk-11" JAVA_VERSION: "11.0.19_7" - VERSION: ${REMOTING_VERSION} + VERSION: ${DOCKER_AGENT_VERSION} jdk17-nanoserver-1809: image: jdk17-nanoserver-1809 build: @@ -14,7 +14,7 @@ services: args: JAVA_HOME: "C:/openjdk-17" JAVA_VERSION: "17.0.7_7" - VERSION: ${REMOTING_VERSION} + VERSION: ${DOCKER_AGENT_VERSION} jdk11-windowsservercore-ltsc2019: image: jdk11-windowsservercore-ltsc2019 build: @@ -22,7 +22,7 @@ services: args: JAVA_HOME: "C:/openjdk-11" JAVA_VERSION: "11.0.19_7" - VERSION: ${REMOTING_VERSION} + VERSION: ${DOCKER_AGENT_VERSION} jdk17-windowsservercore-ltsc2019: image: jdk17-windowsservercore-ltsc2019 build: @@ -30,4 +30,4 @@ services: args: JAVA_HOME: "C:/openjdk-17" JAVA_VERSION: "17.0.7_7" - VERSION: ${REMOTING_VERSION} + VERSION: ${DOCKER_AGENT_VERSION} diff --git a/build.ps1 b/build.ps1 index 8db02488..4a46c93f 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,26 +3,28 @@ Param( [Parameter(Position=1)] [String] $Target = "build", [String] $Build = '', - [String] $RemotingVersion = '3131.vf2b_b_798b_ce99', + [String] $DockerAgentVersion = '3131.vf2b_b_798b_ce99-2', [String] $BuildNumber = '1', - [switch] $PushVersions = $false, - [switch] $DisableEnvProps = $false + [switch] $PushVersions = $false + # [switch] $PushVersions = $false, + # [switch] $DisableEnvProps = $false ) $ErrorActionPreference = "Stop" -$Repository = 'agent' +$Repository = 'inbound-agent' $Organization = 'jenkins' -if(!$DisableEnvProps) { - Get-Content env.props | ForEach-Object { - $items = $_.Split("=") - if($items.Length -eq 2) { - $name = $items[0].Trim() - $value = $items[1].Trim() - Set-Item -Path "env:$($name)" -Value $value - } - } -} +# TODO: not needed? Commented for now, env.props contains DOCKER_AGENT_VERSION in docker-agent +# if(!$DisableEnvProps) { +# Get-Content env.props | ForEach-Object { +# $items = $_.Split("=") +# if($items.Length -eq 2) { +# $name = $items[0].Trim() +# $value = $items[1].Trim() +# Set-Item -Path "env:$($name)" -Value $value +# } +# } +# } if(![String]::IsNullOrWhiteSpace($env:DOCKERHUB_REPO)) { $Repository = $env:DOCKERHUB_REPO @@ -32,8 +34,8 @@ if(![String]::IsNullOrWhiteSpace($env:DOCKERHUB_ORGANISATION)) { $Organization = $env:DOCKERHUB_ORGANISATION } -if(![String]::IsNullOrWhiteSpace($env:REMOTING_VERSION)) { - $RemotingVersion = $env:REMOTING_VERSION +if(![String]::IsNullOrWhiteSpace($env:DOCKER_AGENT_VERSION)) { + $DockerAgentVersion = $env:DOCKER_AGENT_VERSION } # Check for required commands @@ -61,7 +63,7 @@ Function Test-CommandExists { # this is the jdk version that will be used for the 'bare tag' images, e.g., jdk8-windowsservercore-1809 -> windowsserver-1809 $defaultJdk = '11' $builds = @{} -$env:REMOTING_VERSION = "$RemotingVersion" +$env:DOCKER_AGENT_VERSION = "$DockerAgentVersion" $ProgressPreference = 'SilentlyContinue' # Disable Progress bar for faster downloads Test-CommandExists "docker" @@ -74,16 +76,20 @@ $baseDockerBuildCmd = '{0} build --parallel --pull' -f $baseDockerCmd Invoke-Expression "$baseDockerCmd config --services" 2>$null | ForEach-Object { $image = $_ $items = $image.Split("-") + # Remove the 'jdk' prefix (3 first characters) $jdkMajorVersion = $items[0].Remove(0,3) $windowsType = $items[1] $windowsVersion = $items[2] - + $baseImage = "${windowsType}-${windowsVersion}" - $versionTag = "${RemotingVersion}-${BuildNumber}-${image}" + $versionTag = "${DockerAgentVersion}-${BuildNumber}-${image}" $tags = @( $image, $versionTag ) - if($jdkMajorVersion -eq "$defaultJdk") { - $tags += $baseImage - } + # TODO: keep it here too? (from docker-agent) + # if($jdkMajorVersion -eq "$defaultJdk") { + # $tags += $baseImage + # } + + Write-Host "New Windows image to build ($image): ${Organization}/${Repository}:${baseImage} with JDK ${jdkMajorVersion}" $builds[$image] = @{ 'Tags' = $tags; @@ -114,7 +120,7 @@ function Test-Image { $env:AGENT_IMAGE = $ImageName $env:IMAGE_FOLDER = Invoke-Expression "$baseDockerCmd config" 2>$null | yq -r ".services.${ImageName}.build.context" - $env:VERSION = "$RemotingVersion-$BuildNumber" + $env:VERSION = "$DockerAgentVersion-$BuildNumber" if(Test-Path ".\target\$ImageName") { @@ -180,6 +186,7 @@ if($target -eq "test") { } } +# TODO: dry mode? function Publish-Image { param ( [String] $Build, @@ -207,9 +214,9 @@ if($target -eq "publish") { } if($PushVersions) { - $buildTag = "$RemotingVersion-$BuildNumber-$tag" + $buildTag = "$DockerAgentVersion-$BuildNumber-$tag" if($tag -eq 'latest') { - $buildTag = "$RemotingVersion-$BuildNumber" + $buildTag = "$DockerAgentVersion-$BuildNumber" } Publish-Image "$Build" "${Organization}/${Repository}:${buildTag}" if($lastExitCode -ne 0) { @@ -226,9 +233,9 @@ if($target -eq "publish") { } if($PushVersions) { - $buildTag = "$RemotingVersion-$BuildNumber-$tag" + $buildTag = "$DockerAgentVersion-$BuildNumber-$tag" if($tag -eq 'latest') { - $buildTag = "$RemotingVersion-$BuildNumber" + $buildTag = "$DockerAgentVersion-$BuildNumber" } Publish-Image "$b" "${Organization}/${Repository}:${buildTag}" if($lastExitCode -ne 0) { diff --git a/debian/Dockerfile b/debian/Dockerfile index 70338a7f..d77b892d 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -1,8 +1,8 @@ -ARG version=3131.vf2b_b_798b_ce99-2 +ARG VERSION=3131.vf2b_b_798b_ce99-2 ARG JAVA_MAJOR_VERSION=17 FROM jenkins/agent:"${version}"-jdk"${JAVA_MAJOR_VERSION}" -ARG version=3131.vf2b_b_798b_ce99-2 +ARG VERSION=3131.vf2b_b_798b_ce99-2 LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols" Vendor="Jenkins project" Version="$version" ARG user=jenkins diff --git a/docker-bake.hcl b/docker-bake.hcl index 91af9038..b610ceff 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -30,8 +30,8 @@ variable "IMAGE_TAG" { default = "3071.v7e9b_0dc08466-1" } -#### This is for the "parent" image version to use (jenkins/agent:-) -variable "PARENT_IMAGE_VERSION" { +#### This is for the "parent" image version to use (jenkins/agent:-) +variable "DOCKER_AGENT_VERSION" { default = "3131.vf2b_b_798b_ce99-2" } @@ -52,11 +52,11 @@ target "alpine_jdk11" { context = "." args = { JAVA_MAJOR_VERSION = "11" - version = "${PARENT_IMAGE_VERSION}" + VERSION = "${DOCKER_AGENT_VERSION}" } tags = [ - equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${PARENT_IMAGE_VERSION}-alpine": "", - equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${PARENT_IMAGE_VERSION}-alpine-jdk11": "", + equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${DOCKER_AGENT_VERSION}-alpine": "", + equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${DOCKER_AGENT_VERSION}-alpine-jdk11": "", "${REGISTRY}/${JENKINS_REPO}:alpine", "${REGISTRY}/${JENKINS_REPO}:alpine-jdk11", "${REGISTRY}/${JENKINS_REPO}:latest-alpine", @@ -70,10 +70,10 @@ target "alpine_jdk17" { context = "." args = { JAVA_MAJOR_VERSION = "17" - version = "${PARENT_IMAGE_VERSION}" + VERSION = "${DOCKER_AGENT_VERSION}" } tags = [ - equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${PARENT_IMAGE_VERSION}-alpine-jdk17": "", + equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${DOCKER_AGENT_VERSION}-alpine-jdk17": "", "${REGISTRY}/${JENKINS_REPO}:alpine-jdk17", "${REGISTRY}/${JENKINS_REPO}:latest-alpine-jdk17", ] @@ -85,11 +85,11 @@ target "debian_jdk11" { context = "." args = { JAVA_MAJOR_VERSION = "11" - version = "${PARENT_IMAGE_VERSION}" + VERSION = "${DOCKER_AGENT_VERSION}" } tags = [ - equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${PARENT_IMAGE_VERSION}": "", - equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${PARENT_IMAGE_VERSION}-jdk11": "", + equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${DOCKER_AGENT_VERSION}": "", + equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${DOCKER_AGENT_VERSION}-jdk11": "", "${REGISTRY}/${JENKINS_REPO}:jdk11", "${REGISTRY}/${JENKINS_REPO}:latest", "${REGISTRY}/${JENKINS_REPO}:latest-jdk11", @@ -102,10 +102,10 @@ target "debian_jdk17" { context = "." args = { JAVA_MAJOR_VERSION = "17" - version = "${PARENT_IMAGE_VERSION}" + VERSION = "${DOCKER_AGENT_VERSION}" } tags = [ - equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${PARENT_IMAGE_VERSION}-jdk17": "", + equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${DOCKER_AGENT_VERSION}-jdk17": "", "${REGISTRY}/${JENKINS_REPO}:jdk17", "${REGISTRY}/${JENKINS_REPO}:latest-jdk17", ] diff --git a/make.ps1 b/make.ps1 index fef94c41..ca021c60 100644 --- a/make.ps1 +++ b/make.ps1 @@ -52,19 +52,19 @@ function Build-Image { param ( [String] $Build, [String] $ImageName, - [String] $RemotingVersion, + [String] $DockerAgentVersion, [String] $JdkMajorVersion, [String] $Folder ) Write-Host "Building $Build with name $imageName" - docker build --build-arg "version=${RemotingVersion}" --build-arg "JAVA_MAJOR_VERSION=${JdkMajorVersion}" --tag="${ImageName}" --file="${Folder}/Dockerfile" ./ + docker build --build-arg "VERSION=${DockerAgentVersion}" --build-arg "JAVA_MAJOR_VERSION=${JdkMajorVersion}" --tag="${ImageName}" --file="${Folder}/Dockerfile" ./ } $exitCodes = 0 if(![System.String]::IsNullOrWhiteSpace($Build) -and $builds.ContainsKey($Build)) { foreach($tag in $builds[$Build]['Tags']) { - Build-Image -Build $Build -ImageName "${Organization}/${Repository}:${tag}" -RemotingVersion $DockerAgentVersion -JdkMajorVersion $builds[$Build]['JdkMajorVersion'] -Folder $builds[$Build]['Folder'] + Build-Image -Build $Build -ImageName "${Organization}/${Repository}:${tag}" -DockerAgentVersion $DockerAgentVersion -JdkMajorVersion $builds[$Build]['JdkMajorVersion'] -Folder $builds[$Build]['Folder'] $exitCodes += $lastExitCode if($PushVersions) { @@ -72,14 +72,14 @@ if(![System.String]::IsNullOrWhiteSpace($Build) -and $builds.ContainsKey($Build) if($tag -eq 'latest') { $buildTag = "$VersionTag" } - Build-Image -Build $Build -ImageName "${Organization}/${Repository}:${buildTag}" -RemotingVersion $DockerAgentVersion -JdkMajorVersion $builds[$Build]['JdkMajorVersion'] -Folder $builds[$Build]['Folder'] + Build-Image -Build $Build -ImageName "${Organization}/${Repository}:${buildTag}" -DockerAgentVersion $DockerAgentVersion -JdkMajorVersion $builds[$Build]['JdkMajorVersion'] -Folder $builds[$Build]['Folder'] $exitCodes += $lastExitCode } } } else { foreach($b in $builds.Keys) { foreach($tag in $builds[$b]['Tags']) { - Build-Image -Build $Build -ImageName "${Organization}/${Repository}:${tag}" -RemotingVersion $DockerAgentVersion -JdkMajorVersion $builds[$b]['JdkMajorVersion'] -Folder $builds[$b]['Folder'] + Build-Image -Build $Build -ImageName "${Organization}/${Repository}:${tag}" -DockerAgentVersion $DockerAgentVersion -JdkMajorVersion $builds[$b]['JdkMajorVersion'] -Folder $builds[$b]['Folder'] $exitCodes += $lastExitCode if($PushVersions) { @@ -87,7 +87,7 @@ if(![System.String]::IsNullOrWhiteSpace($Build) -and $builds.ContainsKey($Build) if($tag -eq 'latest') { $buildTag = "$VersionTag" } - Build-Image -Build $Build -ImageName "${Organization}/${Repository}:${buildTag}" -RemotingVersion $DockerAgentVersion -JdkMajorVersion $builds[$b]['JdkMajorVersion'] -Folder $builds[$b]['Folder'] + Build-Image -Build $Build -ImageName "${Organization}/${Repository}:${buildTag}" -DockerAgentVersion $DockerAgentVersion -JdkMajorVersion $builds[$b]['JdkMajorVersion'] -Folder $builds[$b]['Folder'] $exitCodes += $lastExitCode } } diff --git a/tests/inboundAgent.Tests.ps1 b/tests/inboundAgent.Tests.ps1 index 4ac1989b..1c00e24b 100644 --- a/tests/inboundAgent.Tests.ps1 +++ b/tests/inboundAgent.Tests.ps1 @@ -31,7 +31,7 @@ BuildNcatImage Describe "[$global:AGENT_IMAGE] build image" { It 'builds image' { - $exitCode, $stdout, $stderr = Run-Program 'docker' "build --build-arg version=${global:VERSION} --build-arg JAVA_MAJOR_VERSION=${global:JAVA_MAJOR_VERSION} --tag=${global:AGENT_IMAGE} --file $global:FOLDER/Dockerfile ./" + $exitCode, $stdout, $stderr = Run-Program 'docker' "build --build-arg VERSION=${global:VERSION} --build-arg JAVA_MAJOR_VERSION=${global:JAVA_MAJOR_VERSION} --tag=${global:AGENT_IMAGE} --file $global:FOLDER/Dockerfile ./" $exitCode | Should -Be 0 } } @@ -122,7 +122,7 @@ Describe "[$global:AGENT_IMAGE] custom build args" { } It 'builds image with arguments' { - $exitCode, $stdout, $stderr = Run-Program 'docker' "build --build-arg version=${ARG_TEST_VERSION} --build-arg JAVA_MAJOR_VERSION=${global:JAVA_MAJOR_VERSION} --tag=${customImageName} --file=${global:FOLDER}/Dockerfile ./" + $exitCode, $stdout, $stderr = Run-Program 'docker' "build --build-arg VERSION=${ARG_TEST_VERSION} --build-arg JAVA_MAJOR_VERSION=${global:JAVA_MAJOR_VERSION} --tag=${customImageName} --file=${global:FOLDER}/Dockerfile ./" $exitCode | Should -Be 0 $exitCode, $stdout, $stderr = Run-Program 'docker' "run --detach --tty --name $global:CONTAINERNAME $customImageName -Cmd $global:CONTAINERSHELL" diff --git a/tests/tests.bats b/tests/tests.bats index fd4633e9..8dc4abcd 100755 --- a/tests/tests.bats +++ b/tests/tests.bats @@ -58,7 +58,7 @@ SUT_IMAGE="$(get_sut_image)" sut_image="${SUT_IMAGE}-tests-${BATS_TEST_NUMBER}" docker buildx bake \ - --set "${IMAGE}".args.version="${ARG_TEST_VERSION}" \ + --set "${IMAGE}".args.VERSION="${ARG_TEST_VERSION}" \ --set "${IMAGE}".args.user="${TEST_USER}" \ --set "${IMAGE}".platform=linux/"${ARCH}" \ --set "${IMAGE}".tags="${sut_image}" \ diff --git a/updatecli/updatecli.d/jenkins-agent-parent.yaml b/updatecli/updatecli.d/jenkins-agent-parent.yaml deleted file mode 100644 index 38ca58a5..00000000 --- a/updatecli/updatecli.d/jenkins-agent-parent.yaml +++ /dev/null @@ -1,204 +0,0 @@ ---- -name: Bump the parent image `jenkins/agent` version - -scms: - default: - kind: github - spec: - user: "{{ .github.user }}" - email: "{{ .github.email }}" - owner: "{{ .github.owner }}" - repository: "{{ .github.repository }}" - token: "{{ requiredEnv .github.token }}" - username: "{{ .github.username }}" - branch: "{{ .github.branch }}" - -sources: - lastVersion: - kind: githubrelease - name: Get the latest version of the parent image `jenkins/agent` - spec: - owner: jenkinsci - repository: docker-agent - token: "{{ requiredEnv .github.token }}" - username: "{{ .github.username }}" - versionfilter: - kind: latest - -conditions: - checkJdk11AlpineDockerImage: - kind: dockerimage - name: Check if the container image "jenkins/agent:-alpine-jdk11" for linux/amd64 is available - disablesourceinput: true - spec: - architecture: amd64 - image: jenkins/agent - tag: '{{source "lastVersion" }}-alpine-jdk11' - checkJdk17AlpineDockerImage: - kind: dockerimage - name: Check if the container image "jenkins/agent:-alpine-jdk17" for linux/amd64 is available - disablesourceinput: true - spec: - architecture: amd64 - image: jenkins/agent - tag: '{{source "lastVersion" }}-alpine-jdk17' - checkJdk11DebianDockerImages: - kind: dockerimage - name: Check if the container image "jenkins/agent:-jdk11" for linux/amd64 is available - disablesourceinput: true - spec: - architectures: - - amd64 - - arm64 - - arm/v7 - - s390x - - ppc64le - image: jenkins/agent - tag: '{{source "lastVersion" }}-jdk11' - checkJdk17DebianDockerImages: - kind: dockerimage - name: Check if the container image "jenkins/agent:-jdk17" for linux/amd64 is available - disablesourceinput: true - spec: - architectures: - - amd64 - - arm64 - - arm/v7 - image: jenkins/agent - tag: '{{source "lastVersion" }}-jdk17' - checkJdk11WindowsNanoserver1809DockerImage: - kind: dockerimage - name: Check if the container image "jenkins/agent:-jdk11-nanoserver-1809" for windows/amd64 is available - disablesourceinput: true - spec: - architecture: amd64 - image: jenkins/agent - tag: '{{source "lastVersion" }}-jdk11-nanoserver-1809' - checkJdk17WindowsNanoserver1809DockerImage: - kind: dockerimage - name: Check if the container image "jenkins/agent:-jdk17-nanoserver-1809" for windows/amd64 is available - disablesourceinput: true - spec: - architecture: amd64 - image: jenkins/agent - tag: '{{source "lastVersion" }}-jdk17-nanoserver-1809' - checkJdk11WindowsServer2019DockerImage: - kind: dockerimage - name: Check if the container image "jenkins/agent:-jdk11-windowsservercore-ltsc2019" for windows/amd64 is available - disablesourceinput: true - spec: - architecture: amd64 - image: jenkins/agent - tag: '{{source "lastVersion" }}-jdk11-windowsservercore-ltsc2019' - checkJdk17WindowsServer2019DockerImage: - kind: dockerimage - name: Check if the container image "jenkins/agent:-jdk17-windowsservercore-ltsc2019" for windows/amd64 is available - disablesourceinput: true - spec: - architecture: amd64 - image: jenkins/agent - tag: '{{source "lastVersion" }}-jdk17-windowsservercore-ltsc2019' - -targets: - setJdk11AlpineDockerImage: - name: Bump the parent image `jenkins/agent` version on JDK11 Alpine - kind: dockerfile - spec: - file: alpine/Dockerfile - instruction: - keyword: ARG - matcher: version - scmid: default - setJdk11DebianDockerImage: - name: Bump the parent image `jenkins/agent` version on JDK11 Debian - kind: dockerfile - spec: - file: debian/Dockerfile - instruction: - keyword: ARG - matcher: version - scmid: default - setJdk11WindowsNanoserver1809DockerImage: - name: Bump the parent image `jenkins/agent` version on JDK11 Windows Nanoserver 1809 - kind: dockerfile - spec: - file: windows/nanoserver-1809/Dockerfile - instruction: - keyword: ARG - matcher: version - scmid: default - setJdk11WindowsServer2019DockerImage: - name: Bump the parent image `jenkins/agent` version on JDK11 Windows Server 2019 - kind: dockerfile - spec: - file: windows/windowsservercore-ltsc2019/Dockerfile - instruction: - keyword: ARG - matcher: version - scmid: default - setJdk17AlpineDockerImage: - name: Bump the parent image `jenkins/agent` version on JDK17 Alpine - kind: dockerfile - spec: - file: alpine/Dockerfile - instruction: - keyword: ARG - matcher: version - scmid: default - setJdk17DebianDockerImage: - name: Bump the parent image `jenkins/agent` version on JDK17 Debian - kind: dockerfile - spec: - file: debian/Dockerfile - instruction: - keyword: ARG - matcher: version - scmid: default - setJdk17WindowsNanoserver1809DockerImage: - name: Bump the parent image `jenkins/agent` version on JDK17 Windows Nanoserver 1809 - kind: dockerfile - spec: - file: windows/nanoserver-1809/Dockerfile - instruction: - keyword: ARG - matcher: version - scmid: default - setJdk17WindowsServer2019DockerImage: - name: Bump the parent image `jenkins/agent` version on JDK17 Windows Server 2019 - kind: dockerfile - spec: - file: windows/windowsservercore-ltsc2019/Dockerfile - instruction: - keyword: ARG - matcher: version - scmid: default - setDockerBakeDefaultParentImage: - name: Bump the parent image `jenkins/agent` version on the docker-bake.hcl file - kind: file - spec: - file: docker-bake.hcl - matchpattern: >- - variable(.*)"PARENT_IMAGE_VERSION"(.*){(.*)(\r\n|\r|\n)(.*)default(.*)=(.*) - replacepattern: >- - variable${1}"PARENT_IMAGE_VERSION"${2}{${3}${4}${5}default${6}= "{{ source "lastVersion" }}" - scmid: default - setWindowsMakePwshParentImage: - name: Bump the parent image `jenkins/agent` version on the windows make.ps1 file - kind: file - spec: - file: make.ps1 - matchpattern: >- - \$DockerAgentVersion(.*)=(.*), - replacepattern: >- - $$DockerAgentVersion${1}= '{{ source "lastVersion" }}', - scmid: default - -actions: - default: - kind: github/pullrequest - scmid: default - title: Bump the parent image `jenkins/agent` version to {{ source "lastVersion" }} - spec: - labels: - - dependencies - - jenkins/agent diff --git a/windows/nanoserver-1809/Dockerfile b/windows/nanoserver-1809/Dockerfile index 6a391ad6..107073dd 100644 --- a/windows/nanoserver-1809/Dockerfile +++ b/windows/nanoserver-1809/Dockerfile @@ -21,12 +21,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -ARG version=3131.vf2b_b_798b_ce99-2 +ARG VERSION=3131.vf2b_b_798b_ce99-2 ARG JAVA_MAJOR_VERSION=17 FROM jenkins/agent:"${version}"-jdk"${JAVA_MAJOR_VERSION}"-nanoserver-1809 -ARG version=3131.vf2b_b_798b_ce99-2 +ARG VERSION=3131.vf2b_b_798b_ce99-2 LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols on Windows" Vendor="Jenkins Project" Version="$version" -COPY jenkins-agent.ps1 C:/ProgramData/Jenkins +COPY ./jenkins-agent.ps1 C:/ProgramData/Jenkins ENTRYPOINT ["pwsh.exe", "-f", "C:/ProgramData/Jenkins/jenkins-agent.ps1"] diff --git a/windows/windowsservercore-ltsc2019/Dockerfile b/windows/windowsservercore-ltsc2019/Dockerfile index a1dd1e60..89bf59c9 100644 --- a/windows/windowsservercore-ltsc2019/Dockerfile +++ b/windows/windowsservercore-ltsc2019/Dockerfile @@ -21,12 +21,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -ARG version=3131.vf2b_b_798b_ce99-2 +ARG VERSION=3131.vf2b_b_798b_ce99-2 ARG JAVA_MAJOR_VERSION=17 FROM jenkins/agent:"${version}"-jdk"${JAVA_MAJOR_VERSION}"-windowsservercore-ltsc2019 -ARG version=3131.vf2b_b_798b_ce99-2 +ARG VERSION=3131.vf2b_b_798b_ce99-2 LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols on Windows" Vendor="Jenkins Project" Version="$version" -COPY jenkins-agent.ps1 C:/ProgramData/Jenkins +COPY ./jenkins-agent.ps1 C:/ProgramData/Jenkins ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Jenkins/jenkins-agent.ps1"]