From 4d817e0c40584fcc005864a5bf7bbac01683f7bc Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 26 Jun 2022 14:26:24 -0700 Subject: [PATCH] Update default value of Jenkins version (#1411) * Update default value of Jenkins version * Try and fix tests * Fix ps1 * Minimize diff * Remove HTML from regex * facepalm --- 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 ++-- .../windowsservercore-2019/hotspot/Dockerfile | 4 ++-- 17/alpine/hotspot/Dockerfile | 4 ++-- 17/debian/bullseye-slim/hotspot/Dockerfile | 4 ++-- 17/debian/bullseye/hotspot/Dockerfile | 4 ++-- tests/runtime.Tests.ps1 | 6 +++--- tests/test_helpers.psm1 | 15 ++++++++++----- 12 files changed, 33 insertions(+), 28 deletions(-) diff --git a/11/almalinux/almalinux8/hotspot/Dockerfile b/11/almalinux/almalinux8/hotspot/Dockerfile index ebb1e72597..98073e05a6 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 4d16627442..6696f83b04 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 8c6cffcc59..f133a707f7 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 3d172dd272..2dc2bbc450 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 ea94ea46cd..fed43085fe 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 bcc8eb8162..4831d93159 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 1c3f2aca8a..a95c38c955 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 7d279d7b85..860f5d04e7 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 9fff672a36..a73a645eda 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 diff --git a/tests/runtime.Tests.ps1 b/tests/runtime.Tests.ps1 index 31c750e58a..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 ( @@ -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..a63f5a197a 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,10 +146,15 @@ 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 - } + $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 + if ($res.StatusCode -eq 200) { + return $res.Content.replace('Result: ', '') + } } return $null }