Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fail-build-if-tes…
Browse files Browse the repository at this point in the history
…t-errors

* upstream/master:
  JUnit step
  remove debug traces
  chore: add debug traces
  Update plugin manager
  Support JUnit format for Windows tests
  Add missing cmd validation
  Fail the execution at the end if any publishing failures
  Avoid double quotes
  Support JUnit format for Linux tests
  • Loading branch information
v1v committed Nov 3, 2020
2 parents fb82a47 + 47f7477 commit 5e893a9
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 40 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.tmp
bats/
target/
tests/functions/init.groovy.d/
tests/functions/java_cp/
tests/functions/copy_reference_file.log
Expand All @@ -10,7 +11,7 @@ multiarch/Dockerfile-*
/docker.iml
work-pester-jenkins-windows/
/.idea/

/**/windows/**/jenkins.ps1
/**/windows/**/jenkins-plugin-cli.ps1
/**/windows/**/jenkins-support.psm1

/**/windows/**/jenkins.ps1
/**/windows/**/jenkins-plugin-cli.ps1
/**/windows/**/jenkins-support.psm1
2 changes: 1 addition & 1 deletion 11/alpine/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 11/debian/buster-slim/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 11/debian/buster/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 11/ubuntu/bionic/openj9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 11/windows/windowsservercore-1809/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl.exe -fsSL "$env:PLUGIN_CLI_URL" -o C:/ProgramData/Jenkins/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 11/windows/windowsservercore-1809/openj9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl.exe -fsSL "$env:PLUGIN_CLI_URL" -o C:/ProgramData/Jenkins/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/alpine/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/centos/centos7/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/centos/centos8/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/debian/buster-slim/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/debian/buster/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/debian/stretch/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/ubuntu/bionic/openj9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} "$JENKINS_HOME" "$REF"

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl -fsSL ${PLUGIN_CLI_URL} -o /usr/lib/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/windows/windowsservercore-1809/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl.exe -fsSL "$env:PLUGIN_CLI_URL" -o C:/ProgramData/Jenkins/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
2 changes: 1 addition & 1 deletion 8/windows/windowsservercore-1809/openj9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals

ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.0/jenkins-plugin-manager-2.1.0.jar
ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.1.1/jenkins-plugin-manager-2.1.1.jar
RUN curl.exe -fsSL "$env:PLUGIN_CLI_URL" -o C:/ProgramData/Jenkins/jenkins-plugin-manager.jar

# for main web interface:
Expand Down
7 changes: 6 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ stage('Build') {
}

stage('Test') {
powershell './make.ps1 test'
def windowsTestStatus = powershell('./make.ps1 test', returnStatus: true)
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml')
if (windowsTestStatus > 0) {
error('Windows test stage failed.')
}
}

def branchName = "${env.BRANCH_NAME}"
Expand Down Expand Up @@ -89,6 +93,7 @@ stage('Build') {
builders[label] = {
stage("Test ${label}") {
sh "make test-$label"
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/*.xml')
}
}
}
Expand Down
39 changes: 23 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,37 @@ bats:

prepare-test: bats
git submodule update --init --recursive
mkdir -p target

test-debian: prepare-test
DIRECTORY="8/debian/buster/hotspot" bats/bin/bats tests
test-run-%: prepare-test
DIRECTORY="${DIRECTORY}" bats/bin/bats tests | tee target/results-$*.tap
docker run --rm -v "${PWD}":/usr/src/app \
-w /usr/src/app node:12-alpine \
sh -c "npm install tap-xunit -g && cat target/results-$*.tap | tap-xunit --package='jenkinsci.docker.$*' > target/junit-results-$*.xml"

test-alpine: prepare-test
DIRECTORY="8/alpine/hotspot" bats/bin/bats tests
test-debian: DIRECTORY="8/debian/buster/hotspot"
test-debian: test-run-debian

test-slim: prepare-test
DIRECTORY="8/debian/buster-slim/hotspot" bats/bin/bats tests
test-alpine: DIRECTORY=8/alpine/hotspot
test-alpine: test-run-alpine

test-jdk11: prepare-test
DIRECTORY="11/debian/buster/hotspot" bats/bin/bats tests
test-slim: DIRECTORY=8/debian/buster-slim/hotspot
test-slim: test-run-slim

test-centos: prepare-test
DIRECTORY="8/centos/centos8/hotspot" bats/bin/bats tests
test-jdk11: DIRECTORY=11/debian/buster/hotspot
test-jdk11: test-run-jdk11

test-centos7: prepare-test
DIRECTORY="8/centos/centos7/hotspot" bats/bin/bats tests
test-centos: DIRECTORY=8/centos/centos8/hotspot
test-centos: test-run-centos

test-openj9:
DIRECTORY="8/ubuntu/bionic/openj9" bats/bin/bats tests
test-centos7: DIRECTORY=8/centos/centos7/hotspot
test-centos7: test-run-centos7

test-openj9-jdk11:
DIRECTORY="11/ubuntu/bionic/openj9" bats/bin/bats tests
test-openj9: DIRECTORY=8/ubuntu/bionic/openj9
test-openj9: test-run-openj9

test-openj9-jdk11: DIRECTORY=11/ubuntu/bionic/openj9
test-openj9-jdk11: test-run-openj9-jdk11

test: build prepare-test
@for d in ${DOCKERFILES} ; do \
Expand Down
32 changes: 28 additions & 4 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ if($target -eq "test") {
}

if(![System.String]::IsNullOrWhiteSpace($Build) -and $builds.ContainsKey($Build)) {
$env:FOLDER = $builds[$Build]['Folder']
$TestResults = Invoke-Pester -Path tests -PassThru
$folder = $builds[$Build]['Folder']
$env:FOLDER = $folder
New-Item -Path ".\target\$folder" -Type Directory
$TestResults = Invoke-Pester -Path tests -PassThru -OutputFile ".\target\$folder\junit-results.xml" -OutputFormat JUnitXml
if ($TestResults.FailedCount -gt 0) {
Write-Host "There were $($TestResults.FailedCount) failed tests in $Build"
$testFailed = $true
Expand All @@ -117,8 +119,10 @@ if($target -eq "test") {
Remove-Item -Force env:\FOLDER
} else {
foreach($b in $builds.Keys) {
$env:FOLDER = $builds[$b]['Folder']
$TestResults = Invoke-Pester -Path tests -PassThru
$folder = $builds[$b]['Folder']
$env:FOLDER = $folder
New-Item -Path ".\target\$folder" -Type Directory
$TestResults = Invoke-Pester -Path tests -PassThru -OutputFile ".\target\$folder\junit-results.xml" -OutputFormat JUnitXml
if ($TestResults.FailedCount -gt 0) {
Write-Host "There were $($TestResults.FailedCount) failed tests in $b"
$testFailed = $true
Expand All @@ -139,11 +143,16 @@ if($target -eq "test") {
}

if($target -eq "publish") {
# Only fail the run afterwards in case of any issues when publishing the docker images
$publishFailed = 0
if(![System.String]::IsNullOrWhiteSpace($Build) -and $builds.ContainsKey($Build)) {
foreach($tag in $Builds[$Build]['Tags']) {
Write-Host "Publishing $Build => tag=$tag"
$cmd = "docker push {0}/{1}:{2}" -f $Organization, $Repository, $tag
Invoke-Expression $cmd
if($lastExitCode -ne 0) {
$publishFailed = 1
}

if($PushVersions) {
$buildTag = "$JenkinsVersion-$tag"
Expand All @@ -153,6 +162,9 @@ if($target -eq "publish") {
Write-Host "Publishing $Build => tag=$buildTag"
$cmd = "docker push {0}/{1}:{2}" -f $Organization, $Repository, $buildTag
Invoke-Expression $cmd
if($lastExitCode -ne 0) {
$publishFailed = 1
}
}
}
} else {
Expand All @@ -161,6 +173,9 @@ if($target -eq "publish") {
Write-Host "Publishing $b => tag=$tag"
$cmd = "docker push {0}/{1}:{2}" -f $Organization, $Repository, $tag
Invoke-Expression $cmd
if($lastExitCode -ne 0) {
$publishFailed = 1
}

if($PushVersions) {
$buildTag = "$JenkinsVersion-$tag"
Expand All @@ -170,10 +185,19 @@ if($target -eq "publish") {
Write-Host "Publishing $Build => tag=$buildTag"
$cmd = "docker push {0}/{1}:{2}" -f $Organization, $Repository, $buildTag
Invoke-Expression $cmd
if($lastExitCode -ne 0) {
$publishFailed = 1
}
}
}
}
}

# Fail if any issues when publising the docker images
if($publishFailed -ne 0) {
Write-Error "Publish failed!"
exit 1
}
}

if($lastExitCode -ne 0) {
Expand Down

0 comments on commit 5e893a9

Please sign in to comment.