From 6b44cc41b82f94c07d8d60d30ff91a816db867d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Sun, 30 Jul 2023 19:03:14 +0200 Subject: [PATCH 01/17] fix: set JAVA_MAJOR_VERSION --- build-windows.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build-windows.yaml b/build-windows.yaml index 85bf0a9c..0ec6ed1c 100644 --- a/build-windows.yaml +++ b/build-windows.yaml @@ -5,6 +5,7 @@ services: context: ./ dockerfile: ./windows/nanoserver/Dockerfile args: + JAVA_MAJOR_VERSION: 11 version: ${PARENT_IMAGE_VERSION} WINDOWS_VERSION_TAG: ${NANOSERVER_VERSION_TAG} jdk17-nanoserver: @@ -13,6 +14,7 @@ services: context: ./ dockerfile: ./windows/nanoserver/Dockerfile args: + JAVA_MAJOR_VERSION: 17 version: ${PARENT_IMAGE_VERSION} WINDOWS_VERSION_TAG: ${NANOSERVER_VERSION_TAG} jdk11-windowsservercore: @@ -21,6 +23,7 @@ services: context: ./ dockerfile: ./windows/windowsservercore/Dockerfile args: + JAVA_MAJOR_VERSION: 11 version: ${PARENT_IMAGE_VERSION} WINDOWS_VERSION_TAG: ${WINDOWS_VERSION_TAG} jdk17-windowsservercore: @@ -29,5 +32,6 @@ services: context: ./ dockerfile: ./windows/windowsservercore/Dockerfile args: + JAVA_MAJOR_VERSION: 17 version: ${PARENT_IMAGE_VERSION} WINDOWS_VERSION_TAG: ${WINDOWS_VERSION_TAG} From 3fe2ee53dbe9721ed0c1449afc8a426dc4a5dc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Sun, 30 Jul 2023 19:03:38 +0200 Subject: [PATCH 02/17] chore: output JAVA_MAJOR_VERSION in tests --- tests/inboundAgent.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/inboundAgent.Tests.ps1 b/tests/inboundAgent.Tests.ps1 index 7a47b59a..69ef0bbc 100644 --- a/tests/inboundAgent.Tests.ps1 +++ b/tests/inboundAgent.Tests.ps1 @@ -145,7 +145,7 @@ Describe "[$global:AGENT_IMAGE] custom build args" { } Describe "[$global:AGENT_IMAGE] passing JVM options (slow test)" { - It "shows the java version with --show-version" { + It "shows the java version ${global:JAVA_MAJOR_VERSION} with --show-version" { $exitCode, $stdout, $stderr = Run-Program 'docker' "network create --driver nat jnlp-network" # Launch the netcat utility, listening at port 5000 for 30 sec # bats will capture the output from netcat and compare the first line From 889f075fe8fc05aeeecfca178ae29d1933545d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Sun, 30 Jul 2023 19:04:28 +0200 Subject: [PATCH 03/17] fix: no build number in tags --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 75014b9c..86e0fce7 100644 --- a/build.ps1 +++ b/build.ps1 @@ -84,7 +84,7 @@ Invoke-Expression "$baseDockerCmd config --services" 2>$null | ForEach-Object { $windowsVersion = $items[2] $baseImage = "${windowsType}-${windowsVersion}" - $versionTag = "${ParentImageVersion}-${BuildNumber}-${image}" + $versionTag = "${ParentImageVersion}-${image}" $tags = @( $image, $versionTag ) if($jdkMajorVersion -eq "$defaultJdk") { $tags += $baseImage From 5d4f4a2df226ac22c2a5efcbc9ce21a138a7be74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Sun, 30 Jul 2023 19:05:29 +0200 Subject: [PATCH 04/17] chore: cleanup unused parameters --- Jenkinsfile | 2 +- build.ps1 | 26 +------------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 28da0f73..16303bf3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,7 +76,7 @@ pipeline { docker buildx bake --push --file docker-bake.hcl linux ''' } else { - powershell "& ./build.ps1 -PushVersions -VersionTag $env:TAG_NAME publish" + powershell "& ./build.ps1 publish" } } } diff --git a/build.ps1 b/build.ps1 index 86e0fce7..6a39add0 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,9 +3,7 @@ Param( [Parameter(Position=1)] [String] $Target = "build", [String] $Build = '', - [String] $ParentImageVersion = '3131.vf2b_b_798b_ce99-4', - [String] $BuildNumber = '1', - [switch] $PushVersions = $false + [String] $ParentImageVersion = '3131.vf2b_b_798b_ce99-4' ) $ErrorActionPreference ='Stop' @@ -213,17 +211,6 @@ if($target -eq "publish") { if($lastExitCode -ne 0) { $publishFailed = 1 } - - if($PushVersions) { - $buildTag = "$ParentImageVersion-$BuildNumber-$tag" - if($tag -eq 'latest') { - $buildTag = "$ParentImageVersion-$BuildNumber" - } - Publish-Image "$Build" "${Organization}/${Repository}:${buildTag}" - if($lastExitCode -ne 0) { - $publishFailed = 1 - } - } } } else { foreach($b in $builds.Keys) { @@ -232,17 +219,6 @@ if($target -eq "publish") { if($lastExitCode -ne 0) { $publishFailed = 1 } - - if($PushVersions) { - $buildTag = "$ParentImageVersion-$BuildNumber-$tag" - if($tag -eq 'latest') { - $buildTag = "$ParentImageVersion-$BuildNumber" - } - Publish-Image "$b" "${Organization}/${Repository}:${buildTag}" - if($lastExitCode -ne 0) { - $publishFailed = 1 - } - } } } } From 8195981b4a9c6922f9d19626fe84fdc2ec58652b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Sun, 30 Jul 2023 19:12:52 +0200 Subject: [PATCH 05/17] fix: no comma anymore --- updatecli/updatecli.d/docker-agent.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updatecli/updatecli.d/docker-agent.yaml b/updatecli/updatecli.d/docker-agent.yaml index 5be71703..7be42be4 100644 --- a/updatecli/updatecli.d/docker-agent.yaml +++ b/updatecli/updatecli.d/docker-agent.yaml @@ -154,7 +154,7 @@ targets: matchpattern: >- \$ParentImageVersion(.*)=(.*), replacepattern: >- - $ParentImageVersion${1}= '{{ source "lastVersion" }}', + $ParentImageVersion${1}= '{{ source "lastVersion" }}' scmid: default actions: From fdcf9783f2c6d5f32942b27c68a0b26c08f0fd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 11:15:18 +0200 Subject: [PATCH 06/17] fix: use env:VERSION_TAG --- Jenkinsfile | 2 +- build.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 16303bf3..00d971b8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,7 +76,7 @@ pipeline { docker buildx bake --push --file docker-bake.hcl linux ''' } else { - powershell "& ./build.ps1 publish" + powershell "& ./build.ps1 -VersionTag $env:TAG_NAME publish" } } } diff --git a/build.ps1 b/build.ps1 index 6a39add0..5420c50b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,6 +3,7 @@ Param( [Parameter(Position=1)] [String] $Target = "build", [String] $Build = '', + [String] $VersionTag = 'NEXT_TAG_VERSION', [String] $ParentImageVersion = '3131.vf2b_b_798b_ce99-4' ) @@ -82,8 +83,7 @@ Invoke-Expression "$baseDockerCmd config --services" 2>$null | ForEach-Object { $windowsVersion = $items[2] $baseImage = "${windowsType}-${windowsVersion}" - $versionTag = "${ParentImageVersion}-${image}" - $tags = @( $image, $versionTag ) + $tags = @( $image, $VersionTag ) if($jdkMajorVersion -eq "$defaultJdk") { $tags += $baseImage } From 3dd9d34b37b506b4e0d73f0564bc177f7e4ccbfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 11:23:46 +0200 Subject: [PATCH 07/17] chore: restore --- Jenkinsfile | 2 +- build.ps1 | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 00d971b8..28da0f73 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,7 +76,7 @@ pipeline { docker buildx bake --push --file docker-bake.hcl linux ''' } else { - powershell "& ./build.ps1 -VersionTag $env:TAG_NAME publish" + powershell "& ./build.ps1 -PushVersions -VersionTag $env:TAG_NAME publish" } } } diff --git a/build.ps1 b/build.ps1 index 5420c50b..99f2288e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -4,6 +4,7 @@ Param( [String] $Target = "build", [String] $Build = '', [String] $VersionTag = 'NEXT_TAG_VERSION', + [switch] $PushVersions = $false, [String] $ParentImageVersion = '3131.vf2b_b_798b_ce99-4' ) @@ -212,6 +213,17 @@ if($target -eq "publish") { $publishFailed = 1 } } + + if($PushVersions) { + $buildTag = "$VersionTag-$tag" + if($tag -eq 'latest') { + $buildTag = "$VersionTag" + } + Publish-Image "$b" "${Organization}/${Repository}:${buildTag}" + if($lastExitCode -ne 0) { + $publishFailed = 1 + } + } } else { foreach($b in $builds.Keys) { foreach($tag in $Builds[$b]['Tags']) { @@ -220,6 +232,17 @@ if($target -eq "publish") { $publishFailed = 1 } } + + if($PushVersions) { + $buildTag = "$VersionTag-$tag" + if($tag -eq 'latest') { + $buildTag = "$VersionTag" + } + Publish-Image "$b" "${Organization}/${Repository}:${buildTag}" + if($lastExitCode -ne 0) { + $publishFailed = 1 + } + } } } From 279713ec28a40b8bff15186f9db3ed2b604d079c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 11:26:24 +0200 Subject: [PATCH 08/17] fix: concatenate VersionTag and image name for tags --- build.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 99f2288e..40a346ae 100644 --- a/build.ps1 +++ b/build.ps1 @@ -84,7 +84,8 @@ Invoke-Expression "$baseDockerCmd config --services" 2>$null | ForEach-Object { $windowsVersion = $items[2] $baseImage = "${windowsType}-${windowsVersion}" - $tags = @( $image, $VersionTag ) + $versionTag = "${VersionTag}-${image}" + $tags = @( $image, $versionTag ) if($jdkMajorVersion -eq "$defaultJdk") { $tags += $baseImage } From 807426a3f8d9c35d1be3f247ea1e74f0d8152cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 11:32:35 +0200 Subject: [PATCH 09/17] chore: remove duplicated space --- tests/inboundAgent.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/inboundAgent.Tests.ps1 b/tests/inboundAgent.Tests.ps1 index 69ef0bbc..e0ba4780 100644 --- a/tests/inboundAgent.Tests.ps1 +++ b/tests/inboundAgent.Tests.ps1 @@ -145,7 +145,7 @@ Describe "[$global:AGENT_IMAGE] custom build args" { } Describe "[$global:AGENT_IMAGE] passing JVM options (slow test)" { - It "shows the java version ${global:JAVA_MAJOR_VERSION} with --show-version" { + It "shows the java version ${global:JAVA_MAJOR_VERSION} with --show-version" { $exitCode, $stdout, $stderr = Run-Program 'docker' "network create --driver nat jnlp-network" # Launch the netcat utility, listening at port 5000 for 30 sec # bats will capture the output from netcat and compare the first line From 751eaba49be9cb5e0024f04c586335353da79d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 11:39:29 +0200 Subject: [PATCH 10/17] fix(?): no collusion between versionTag and VersionTag (??) --- build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 40a346ae..6c37f63a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -84,8 +84,8 @@ Invoke-Expression "$baseDockerCmd config --services" 2>$null | ForEach-Object { $windowsVersion = $items[2] $baseImage = "${windowsType}-${windowsVersion}" - $versionTag = "${VersionTag}-${image}" - $tags = @( $image, $versionTag ) + $completeVersionTag = "${VersionTag}-${image}" + $tags = @( $image, $completeVersionTag ) if($jdkMajorVersion -eq "$defaultJdk") { $tags += $baseImage } From 94fdc29caec6d94667d6bfc905cad2cbf93e44e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 11:53:55 +0200 Subject: [PATCH 11/17] debug --- build.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.ps1 b/build.ps1 index 6c37f63a..3a92a050 100644 --- a/build.ps1 +++ b/build.ps1 @@ -93,6 +93,9 @@ Invoke-Expression "$baseDockerCmd config --services" 2>$null | ForEach-Object { $builds[$image] = @{ 'Tags' = $tags; } + + # TODO: remove, debug only + Write-Host '$_: {0}, $env:WINDOWS_VERSION_NAME: {1}, $image: {2}, $jdkMajorVersion: {3}, $baseImage: {4}, $VersionTag: {5}, $completeVersionTag: {6}' -f $_, $env:WINDOWS_VERSION_NAME, $image, $jdkMajorVersion, $baseImage, $VersionTag, $completeVersionTag } Write-Host '= PREPARE: List of images and tags to be processed:' From 449f38b623526c283f9f85bcae3b4726bae636e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 11:58:29 +0200 Subject: [PATCH 12/17] fix updatecli --- updatecli/updatecli.d/docker-agent.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/updatecli/updatecli.d/docker-agent.yaml b/updatecli/updatecli.d/docker-agent.yaml index 7be42be4..b00097b7 100644 --- a/updatecli/updatecli.d/docker-agent.yaml +++ b/updatecli/updatecli.d/docker-agent.yaml @@ -152,9 +152,9 @@ targets: spec: file: build.ps1 matchpattern: >- - \$ParentImageVersion(.*)=(.*), + ParentImageVersion(.*)=(.*) replacepattern: >- - $ParentImageVersion${1}= '{{ source "lastVersion" }}' + ParentImageVersion${1}= '{{ source "lastVersion" }}' scmid: default actions: From fb66e844d6a53b921cea3b406af0184e390e7302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 12:06:24 +0200 Subject: [PATCH 13/17] fix debug (?) --- build.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 3a92a050..875ec93e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -95,7 +95,8 @@ Invoke-Expression "$baseDockerCmd config --services" 2>$null | ForEach-Object { } # TODO: remove, debug only - Write-Host '$_: {0}, $env:WINDOWS_VERSION_NAME: {1}, $image: {2}, $jdkMajorVersion: {3}, $baseImage: {4}, $VersionTag: {5}, $completeVersionTag: {6}' -f $_, $env:WINDOWS_VERSION_NAME, $image, $jdkMajorVersion, $baseImage, $VersionTag, $completeVersionTag + $debug = '$_: {0}, $env:WINDOWS_VERSION_NAME: {1}, $image: {2}, $jdkMajorVersion: {3}, $baseImage: {4}, $VersionTag: {5}, $completeVersionTag: {6}' -f $_, $env:WINDOWS_VERSION_NAME, $image, $jdkMajorVersion, $baseImage, $VersionTag, $completeVersionTag + Write-Host $debug } Write-Host '= PREPARE: List of images and tags to be processed:' From bdf380be51200d28cd1e614c8aa2912014a5c819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 12:08:23 +0200 Subject: [PATCH 14/17] remove debug --- build.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.ps1 b/build.ps1 index 875ec93e..6c37f63a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -93,10 +93,6 @@ Invoke-Expression "$baseDockerCmd config --services" 2>$null | ForEach-Object { $builds[$image] = @{ 'Tags' = $tags; } - - # TODO: remove, debug only - $debug = '$_: {0}, $env:WINDOWS_VERSION_NAME: {1}, $image: {2}, $jdkMajorVersion: {3}, $baseImage: {4}, $VersionTag: {5}, $completeVersionTag: {6}' -f $_, $env:WINDOWS_VERSION_NAME, $image, $jdkMajorVersion, $baseImage, $VersionTag, $completeVersionTag - Write-Host $debug } Write-Host '= PREPARE: List of images and tags to be processed:' From 2782b79d4a47390ca91b334faaa5480fbe1072f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 13:45:54 +0200 Subject: [PATCH 15/17] restore updatecli, to be fixed in another PR --- updatecli/updatecli.d/docker-agent.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/updatecli/updatecli.d/docker-agent.yaml b/updatecli/updatecli.d/docker-agent.yaml index b00097b7..5be71703 100644 --- a/updatecli/updatecli.d/docker-agent.yaml +++ b/updatecli/updatecli.d/docker-agent.yaml @@ -152,9 +152,9 @@ targets: spec: file: build.ps1 matchpattern: >- - ParentImageVersion(.*)=(.*) + \$ParentImageVersion(.*)=(.*), replacepattern: >- - ParentImageVersion${1}= '{{ source "lastVersion" }}' + $ParentImageVersion${1}= '{{ source "lastVersion" }}', scmid: default actions: From c0a409ec7ba4af056a7879ac23e5360de46f4e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 13:48:31 +0200 Subject: [PATCH 16/17] fix PushVersion restoration --- build.ps1 | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/build.ps1 b/build.ps1 index 6c37f63a..5cda4e4e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -213,17 +213,17 @@ if($target -eq "publish") { if($lastExitCode -ne 0) { $publishFailed = 1 } - } - if($PushVersions) { - $buildTag = "$VersionTag-$tag" - if($tag -eq 'latest') { - $buildTag = "$VersionTag" - } - Publish-Image "$b" "${Organization}/${Repository}:${buildTag}" - if($lastExitCode -ne 0) { - $publishFailed = 1 - } + if($PushVersions) { + $buildTag = "$VersionTag-$tag" + if($tag -eq 'latest') { + $buildTag = "$VersionTag" + } + Publish-Image "$b" "${Organization}/${Repository}:${buildTag}" + if($lastExitCode -ne 0) { + $publishFailed = 1 + } + } } } else { foreach($b in $builds.Keys) { @@ -232,16 +232,16 @@ if($target -eq "publish") { if($lastExitCode -ne 0) { $publishFailed = 1 } - } - if($PushVersions) { - $buildTag = "$VersionTag-$tag" - if($tag -eq 'latest') { - $buildTag = "$VersionTag" - } - Publish-Image "$b" "${Organization}/${Repository}:${buildTag}" - if($lastExitCode -ne 0) { - $publishFailed = 1 + if($PushVersions) { + $buildTag = "$VersionTag-$tag" + if($tag -eq 'latest') { + $buildTag = "$VersionTag" + } + Publish-Image "$b" "${Organization}/${Repository}:${buildTag}" + if($lastExitCode -ne 0) { + $publishFailed = 1 + } } } } From 653ac2ed43de2dc97a9bc504f7b59e4255850535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Mon, 31 Jul 2023 14:02:10 +0200 Subject: [PATCH 17/17] do not put ParentImageVersion as last parameter position to keep a comma at its end of line --- build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5cda4e4e..c05cda1e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -4,8 +4,8 @@ Param( [String] $Target = "build", [String] $Build = '', [String] $VersionTag = 'NEXT_TAG_VERSION', - [switch] $PushVersions = $false, - [String] $ParentImageVersion = '3131.vf2b_b_798b_ce99-4' + [String] $ParentImageVersion = '3131.vf2b_b_798b_ce99-4', + [switch] $PushVersions = $false ) $ErrorActionPreference ='Stop'