From a858a55d0f6beb1856f5bab5bc4ef63438099911 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 26 Jun 2022 11:25:11 -0700 Subject: [PATCH 1/6] Update default value of Jenkins version --- 11/almalinux/almalinux8/hotspot/Dockerfile | 4 ++-- 11/alpine/hotspot/Dockerfile | 4 ++-- 11/centos/centos7/hotspot/Dockerfile | 4 ++-- 11/debian/bullseye-slim/hotspot/Dockerfile | 4 ++-- 11/debian/bullseye/hotspot/Dockerfile | 4 ++-- 11/rhel/ubi8/hotspot/Dockerfile | 4 ++-- 11/windows/windowsservercore-2019/hotspot/Dockerfile | 4 ++-- 17/alpine/hotspot/Dockerfile | 4 ++-- 17/debian/bullseye-slim/hotspot/Dockerfile | 4 ++-- 17/debian/bullseye/hotspot/Dockerfile | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/11/almalinux/almalinux8/hotspot/Dockerfile b/11/almalinux/almalinux8/hotspot/Dockerfile index 741f91064c..e239f74ad2 100644 --- a/11/almalinux/almalinux8/hotspot/Dockerfile +++ b/11/almalinux/almalinux8/hotspot/Dockerfile @@ -66,10 +66,10 @@ RUN curl -fsSL "https://github.com/krallin/tini/releases/download/${TINI_VERSION # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/11/alpine/hotspot/Dockerfile b/11/alpine/hotspot/Dockerfile index a5dda8fc19..3654b8d435 100644 --- a/11/alpine/hotspot/Dockerfile +++ b/11/alpine/hotspot/Dockerfile @@ -66,10 +66,10 @@ RUN mkdir -p ${REF}/init.groovy.d # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/11/centos/centos7/hotspot/Dockerfile b/11/centos/centos7/hotspot/Dockerfile index 2ca7c917d3..13fdf9b57b 100644 --- a/11/centos/centos7/hotspot/Dockerfile +++ b/11/centos/centos7/hotspot/Dockerfile @@ -75,10 +75,10 @@ RUN curl -fsSL "https://github.com/krallin/tini/releases/download/${TINI_VERSION # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.289.3} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=996dfd29d5f933546af9e9f77c29b371fb0627b8266b6c9f134ac2e0f1248b87 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/11/debian/bullseye-slim/hotspot/Dockerfile b/11/debian/bullseye-slim/hotspot/Dockerfile index f78cf8ea64..085635bdee 100644 --- a/11/debian/bullseye-slim/hotspot/Dockerfile +++ b/11/debian/bullseye-slim/hotspot/Dockerfile @@ -69,10 +69,10 @@ RUN mkdir -p ${REF}/init.groovy.d # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/11/debian/bullseye/hotspot/Dockerfile b/11/debian/bullseye/hotspot/Dockerfile index 4874f036a1..d1d8730d7e 100644 --- a/11/debian/bullseye/hotspot/Dockerfile +++ b/11/debian/bullseye/hotspot/Dockerfile @@ -67,10 +67,10 @@ RUN mkdir -p ${REF}/init.groovy.d # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/11/rhel/ubi8/hotspot/Dockerfile b/11/rhel/ubi8/hotspot/Dockerfile index eb65080688..66e2254195 100644 --- a/11/rhel/ubi8/hotspot/Dockerfile +++ b/11/rhel/ubi8/hotspot/Dockerfile @@ -68,10 +68,10 @@ RUN curl -fsSL "https://github.com/krallin/tini/releases/download/${TINI_VERSION # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/11/windows/windowsservercore-2019/hotspot/Dockerfile b/11/windows/windowsservercore-2019/hotspot/Dockerfile index f96a642a44..bf0d2766be 100644 --- a/11/windows/windowsservercore-2019/hotspot/Dockerfile +++ b/11/windows/windowsservercore-2019/hotspot/Dockerfile @@ -40,10 +40,10 @@ RUN New-Item -ItemType Directory -Force -Path C:/ProgramData/Jenkins/Reference/i # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/17/alpine/hotspot/Dockerfile b/17/alpine/hotspot/Dockerfile index a65ed1a312..79def8a2b8 100644 --- a/17/alpine/hotspot/Dockerfile +++ b/17/alpine/hotspot/Dockerfile @@ -67,10 +67,10 @@ RUN mkdir -p ${REF}/init.groovy.d # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/17/debian/bullseye-slim/hotspot/Dockerfile b/17/debian/bullseye-slim/hotspot/Dockerfile index b757ce4429..806d5e30f6 100644 --- a/17/debian/bullseye-slim/hotspot/Dockerfile +++ b/17/debian/bullseye-slim/hotspot/Dockerfile @@ -69,10 +69,10 @@ RUN mkdir -p ${REF}/init.groovy.d # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war diff --git a/17/debian/bullseye/hotspot/Dockerfile b/17/debian/bullseye/hotspot/Dockerfile index e2cfb78ba9..fcea88f628 100644 --- a/17/debian/bullseye/hotspot/Dockerfile +++ b/17/debian/bullseye/hotspot/Dockerfile @@ -67,10 +67,10 @@ RUN mkdir -p ${REF}/init.groovy.d # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.356} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=4dfe49cd7422ec4317a7c7a7c083f40fa475a58a7747bd94187b2cf222006ac0 +ARG JENKINS_SHA=1163c4554dc93439c5eef02b06a8d74f98ca920bbc012c2b8a089d414cfa8075 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war From 94fea0da0ddc800d8b97a4af8679e80d2b6872ca Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 26 Jun 2022 12:39:26 -0700 Subject: [PATCH 2/6] Try and fix tests --- tests/runtime.Tests.ps1 | 4 ++-- tests/test_helpers.psm1 | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/runtime.Tests.ps1 b/tests/runtime.Tests.ps1 index 31c750e58a..5a7023ad76 100644 --- a/tests/runtime.Tests.ps1 +++ b/tests/runtime.Tests.ps1 @@ -100,11 +100,11 @@ Describe "[$TEST_TAG] passing JVM parameters" { } function Get-Csp-Value() { - return (Get-JenkinsWebpage $SUT_CONTAINER "/systemInfo").Replace("","`n").Replace("", "").Split("`n") | Select-String -Pattern 'hudson.model.DirectoryBrowserSupport.CSP' + return (Run-In-Script-Console $SUT_CONTAINER "System.getProperty('hudson.model.DirectoryBrowserSupport.CSP')") } function Get-Timezone-Value() { - return (Get-JenkinsWebpage $SUT_CONTAINER "/systemInfo").Replace("","`n").Replace("", "").Split("`n") | Select-String -Pattern 'user.timezone' + return (Run-In-Script-Console $SUT_CONTAINER "System.getProperty('user.timezone')") } } diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 index 898a9c3438..cb1127afc0 100644 --- a/tests/test_helpers.psm1 +++ b/tests/test_helpers.psm1 @@ -154,6 +154,29 @@ function Get-JenkinsWebpage($Container, $Url) { return $null } +function Run-In-Script-Console($Container, $Script) { + $jenkinsPassword = Get-JenkinsPassword $Container + $jenkinsUrl = Get-JenkinsUrl $Container + if ($null -ne $jenkinsPassword) { + $pair = "admin:$($jenkinsPassword)" + $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) + $basicAuthValue = "Basic $encodedCreds" + $Headers = @{ + Authorization = $basicAuthValue + } + $crumb = (Invoke-RestMethod -Uri $('{0}{1}' -f $jenkinsUrl, '/crumbIssuer/api/json') -Headers $headers -TimeoutSec 60 -Method Get).crumb + $crumbHeaders = @{ + "Jenkins-Crumb" = $crumb + Authorization = $basicAuthValue + } + $res = Invoke-WebRequest -Uri $('{0}{1}' -f $jenkinsUrl, '/scriptText') -Headers $crumbHeaders -TimeoutSec 60 -Method Post -Body "script=\"$Script\"" + if ($res.StatusCode -eq 200) { + return $res.Content.replace('Result: ', '') + } + } + return $null +} + function Test-Url($Container, $Url) { $jenkinsPassword = Get-JenkinsPassword $Container $jenkinsUrl = Get-JenkinsUrl $Container From 2ff32d0a969cf4207927f57083b366b8e75c8b38 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 26 Jun 2022 13:35:47 -0700 Subject: [PATCH 3/6] Fix ps1 --- tests/test_helpers.psm1 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 index cb1127afc0..a666bcd1b1 100644 --- a/tests/test_helpers.psm1 +++ b/tests/test_helpers.psm1 @@ -161,15 +161,13 @@ function Run-In-Script-Console($Container, $Script) { $pair = "admin:$($jenkinsPassword)" $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) $basicAuthValue = "Basic $encodedCreds" - $Headers = @{ - Authorization = $basicAuthValue + $headers = @{ Authorization = $basicAuthValue } + $crumb = (Invoke-RestMethod -Uri $('{0}{1}' -f $jenkinsUrl, '/crumbIssuer/api/json') -Headers $headers -TimeoutSec 60 -Method Get -SessionVariable session -UseBasicParsing).crumb + if ($null -ne $crumb) { + $headers += @{ "Jenkins-Crumb" = $crumb } } - $crumb = (Invoke-RestMethod -Uri $('{0}{1}' -f $jenkinsUrl, '/crumbIssuer/api/json') -Headers $headers -TimeoutSec 60 -Method Get).crumb - $crumbHeaders = @{ - "Jenkins-Crumb" = $crumb - Authorization = $basicAuthValue - } - $res = Invoke-WebRequest -Uri $('{0}{1}' -f $jenkinsUrl, '/scriptText') -Headers $crumbHeaders -TimeoutSec 60 -Method Post -Body "script=\"$Script\"" + $body = @{ script = $Script } + $res = Invoke-WebRequest -Uri $('{0}{1}' -f $jenkinsUrl, '/scriptText') -Headers $headers -TimeoutSec 60 -Method Post -WebSession $session -UseBasicParsing -Body $body if ($res.StatusCode -eq 200) { return $res.Content.replace('Result: ', '') } From de70582fe9e3a69f4ed6d7b17eb1e96887f8abce Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 26 Jun 2022 14:05:04 -0700 Subject: [PATCH 4/6] Minimize diff --- tests/test_helpers.psm1 | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 index a666bcd1b1..980843ff12 100644 --- a/tests/test_helpers.psm1 +++ b/tests/test_helpers.psm1 @@ -137,7 +137,7 @@ function Get-JenkinsPassword($Container) { return $null } -function Get-JenkinsWebpage($Container, $Url) { +function Run-In-Script-Console($Container, $Script) { $jenkinsPassword = Get-JenkinsPassword $Container $jenkinsUrl = Get-JenkinsUrl $Container if($null -ne $jenkinsPassword) { @@ -146,33 +146,17 @@ function Get-JenkinsWebpage($Container, $Url) { $basicAuthValue = "Basic $encodedCreds" $Headers = @{ Authorization = $basicAuthValue } - $res = Invoke-WebRequest -Uri $('{0}{1}' -f $jenkinsUrl, $Url) -Headers $Headers -TimeoutSec 60 -Method Get -UseBasicParsing - if($res.StatusCode -eq 200) { - return $res.Content - } - } - return $null -} - -function Run-In-Script-Console($Container, $Script) { - $jenkinsPassword = Get-JenkinsPassword $Container - $jenkinsUrl = Get-JenkinsUrl $Container - if ($null -ne $jenkinsPassword) { - $pair = "admin:$($jenkinsPassword)" - $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) - $basicAuthValue = "Basic $encodedCreds" - $headers = @{ Authorization = $basicAuthValue } - $crumb = (Invoke-RestMethod -Uri $('{0}{1}' -f $jenkinsUrl, '/crumbIssuer/api/json') -Headers $headers -TimeoutSec 60 -Method Get -SessionVariable session -UseBasicParsing).crumb + $crumb = (Invoke-RestMethod -Uri $('{0}{1}' -f $jenkinsUrl, '/crumbIssuer/api/json') -Headers $Headers -TimeoutSec 60 -Method Get -SessionVariable session -UseBasicParsing).crumb if ($null -ne $crumb) { $headers += @{ "Jenkins-Crumb" = $crumb } } $body = @{ script = $Script } - $res = Invoke-WebRequest -Uri $('{0}{1}' -f $jenkinsUrl, '/scriptText') -Headers $headers -TimeoutSec 60 -Method Post -WebSession $session -UseBasicParsing -Body $body + $res = Invoke-WebRequest -Uri $('{0}{1}' -f $jenkinsUrl, '/scriptText') -Headers $Headers -TimeoutSec 60 -Method Post -WebSession $session -UseBasicParsing -Body $body if ($res.StatusCode -eq 200) { return $res.Content.replace('Result: ', '') } } - return $null + return $null } function Test-Url($Container, $Url) { From 7d250251d7d61a8c9395132410fef3485b58f67f Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 26 Jun 2022 14:06:26 -0700 Subject: [PATCH 5/6] Remove HTML from regex --- tests/runtime.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/runtime.Tests.ps1 b/tests/runtime.Tests.ps1 index 5a7023ad76..026ff4bfa1 100644 --- a/tests/runtime.Tests.ps1 +++ b/tests/runtime.Tests.ps1 @@ -71,7 +71,7 @@ Describe "[$TEST_TAG] passing JVM parameters" { $cspSetting = @' -Dhudson.model.DirectoryBrowserSupport.CSP=\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';\" '@ - $cspRegex = [regex]::Escape("default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';") + $cspRegex = [regex]::Escape("default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';") function Start-With-Opts() { Param ( From c5e08020c8511eb7523bd5c7eef3f8c8a065f24c Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 26 Jun 2022 14:13:29 -0700 Subject: [PATCH 6/6] facepalm --- tests/test_helpers.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 index 980843ff12..a63f5a197a 100644 --- a/tests/test_helpers.psm1 +++ b/tests/test_helpers.psm1 @@ -148,7 +148,7 @@ function Run-In-Script-Console($Container, $Script) { $crumb = (Invoke-RestMethod -Uri $('{0}{1}' -f $jenkinsUrl, '/crumbIssuer/api/json') -Headers $Headers -TimeoutSec 60 -Method Get -SessionVariable session -UseBasicParsing).crumb if ($null -ne $crumb) { - $headers += @{ "Jenkins-Crumb" = $crumb } + $Headers += @{ "Jenkins-Crumb" = $crumb } } $body = @{ script = $Script } $res = Invoke-WebRequest -Uri $('{0}{1}' -f $jenkinsUrl, '/scriptText') -Headers $Headers -TimeoutSec 60 -Method Post -WebSession $session -UseBasicParsing -Body $body