From bdc6a76903338831945a2e753669a8b8d7f89434 Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Fri, 29 Mar 2019 10:46:57 +0100 Subject: [PATCH 1/7] First stab at adding PCT ITs for the Docker image --- Jenkinsfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index dc3a75011..c605787a8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,3 +53,22 @@ for (int i = 0; i < platforms.size(); ++i) { /* Execute our platforms in parallel */ parallel(branches) + +node('docker') { + checkout scm + + stage('Build Docker Image') { + sh 'make docker' + } + + stage("Run known successful case(s)") { + sh '''docker run --rm \ + -v $(pwd)/out:/pct/out -e JDK_VERSION=11 \ + -e ARTIFACT_ID=buildtriggerbadge -e VERSION=buildtriggerbadge-2.10 \ + jenkins/pct > output + ''' + + sh 'cat output | grep "Tests : Success"' + + } +} From f19d36b1114f68d64a50697d91ad01df282283c3 Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Fri, 29 Mar 2019 12:05:59 +0100 Subject: [PATCH 2/7] grep the right file :facepalm: --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c605787a8..5690884a9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -65,10 +65,11 @@ node('docker') { sh '''docker run --rm \ -v $(pwd)/out:/pct/out -e JDK_VERSION=11 \ -e ARTIFACT_ID=buildtriggerbadge -e VERSION=buildtriggerbadge-2.10 \ - jenkins/pct > output + jenkins/pct ''' + archiveArtifacts artifacts: "out/**" - sh 'cat output | grep "Tests : Success"' + sh 'cat out/pct-report.html | grep "Tests : Success"' } } From ad6e20bad23631d9b048f42222d1a8cff2c04643 Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Mon, 1 Apr 2019 13:05:39 +0200 Subject: [PATCH 3/7] Download Jenkins.war to run always on the same (not used yet in PCT run though) --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 5690884a9..42e57f0cb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -61,6 +61,12 @@ node('docker') { sh 'make docker' } + stage('Download Jenkins 2.164.1') { + sh '''curl -sL http://mirrors.jenkins.io/war-stable/2.164.1/jenkins.war --output-document jenkins.war + echo "65543f5632ee54344f3351b34b305702df12393b3196a95c3771ddb3819b220b jenkins.war" | sha256sum --check + ''' + } + stage("Run known successful case(s)") { sh '''docker run --rm \ -v $(pwd)/out:/pct/out -e JDK_VERSION=11 \ From 8d1687068ce5e2c01684f4d89d29a4fcab12e7d7 Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Mon, 1 Apr 2019 13:06:25 +0200 Subject: [PATCH 4/7] Always run on the same jenkins.war (2.164.1) --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 42e57f0cb..73b7f43a2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,6 +69,7 @@ node('docker') { stage("Run known successful case(s)") { sh '''docker run --rm \ + -v $(pwd)/jenkins.war:/pct/jenkins.war:ro -v $(pwd)/out:/pct/out -e JDK_VERSION=11 \ -e ARTIFACT_ID=buildtriggerbadge -e VERSION=buildtriggerbadge-2.10 \ jenkins/pct From 527bcfecac59d7c92e96c073fb73e16b1dd74525 Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Tue, 2 Apr 2019 14:46:58 +0200 Subject: [PATCH 5/7] facepalm, wrong CLI switch --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 73b7f43a2..c07c3e67d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,7 +62,7 @@ node('docker') { } stage('Download Jenkins 2.164.1') { - sh '''curl -sL http://mirrors.jenkins.io/war-stable/2.164.1/jenkins.war --output-document jenkins.war + sh '''curl -sL http://mirrors.jenkins.io/war-stable/2.164.1/jenkins.war --output jenkins.war echo "65543f5632ee54344f3351b34b305702df12393b3196a95c3771ddb3819b220b jenkins.war" | sha256sum --check ''' } From cb73b2d08ef6b46f4606cd6e7828653e4eb84d06 Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Tue, 2 Apr 2019 15:23:56 +0200 Subject: [PATCH 6/7] Revert "Merge pull request #115 from raul-arabaolaza/JENKINS-56312" This reverts commit 7d59f12188554dd5859ad66f986c0cdfa236e668, reversing changes made to 661782e542e107b5a1468681a65baa0ce3d7dbef. --- README.md | 15 --------------- .../jenkins/tools/test/PluginCompatTester.java | 5 ++--- src/main/docker/run-pct.sh | 14 ++------------ 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 0a4d79e45..7459557bb 100644 --- a/README.md +++ b/README.md @@ -39,21 +39,6 @@ The command below will run PCT for a branch in a custom repository. docker run --rm -v maven-repo:/root/.m2 -v $(pwd)/out:/pct/out -e CHECKOUT_SRC=https://github.com/oleg-nenashev/job-restrictions-plugin.git -e VERSION=JENKINS-26374 jenkins/pct ``` -#### Full PCT runs using a war file as input with Docker - -The PCT cli supports to pass a war file containing plugins (generated with Custom war Packager for example) as input, in this case the version of -the plugins is infered from the war file contents. - -In such scenarios is tipical to want to run the PCT for all plugins contained in the war file, to avoid having to spawn a new docker container for each plugin -you can use the env variables `DO_NOT_OVERRIDE_PCT_CHECKOUT=true` and `FAIL_ON_ERROR=false` to let the PCT CLI (instead of the `run-pct` script) checkout the proper -versions of the plugins and make sure the PCT does not stop before testing all plugins. - -By using those env variables you can pass a comma separated list of plugins ids using the `ARTIFACT_ID` env variable - -```shell -docker run -ti --rm -v maven-repo:/root/.m2 -v $(pwd)/out:/pct/out -v my/jenkins.war:/pct/jenkins.war:ro -e ARTIFACT_ID=ssh-slaves,credentials -e DO_NOT_OVERRIDE_PCT_CHECKOUT=true -e FAIL_ON_ERROR=false jenkins/pct -``` - #### Configuration Environment variables: diff --git a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java index 22e24c1f3..aca9da82f 100644 --- a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java +++ b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java @@ -611,9 +611,8 @@ private UpdateSite.Data scanWAR(File war, Map pluginGroupIds) th top.put("core", new JSONObject().accumulate("name", "core").accumulate("version", m.group(1)).accumulate("url", "https://foobar")); } - // We should also scan detached plugins to make sure we get the proper groupId for detached not using the - // default org.jenkins-ci one - m = Pattern.compile("WEB-INF/(?:(optional-|detached-))?plugins/([^/.]+)[.][hj]pi").matcher(name); + //TODO: should it also scan detached plugins info? + m = Pattern.compile("WEB-INF/(?:optional-)?plugins/([^/.]+)[.][hj]pi").matcher(name); if (m.matches()) { JSONObject plugin = new JSONObject().accumulate("url", ""); InputStream is = jf.getInputStream(entry); diff --git a/src/main/docker/run-pct.sh b/src/main/docker/run-pct.sh index 5ba0b6a3b..d04f90ce4 100755 --- a/src/main/docker/run-pct.sh +++ b/src/main/docker/run-pct.sh @@ -26,16 +26,6 @@ fi CUSTOM_MAVEN_SETTINGS=${M2_SETTINGS_FILE:-"/pct/m2-settings.xml"} -# Set failOnError by default unless env FAIL_ON_ERROR is false -FAIL_ON_ERROR_ARG="" -if [ -n "${FAIL_ON_ERROR}" ]; then - if [ "${FAIL_ON_ERROR}" != "false" ] ; then - FAIL_ON_ERROR_ARG="-failOnError" - fi -else - FAIL_ON_ERROR_ARG="-failOnError" -fi - if [ -f "${CUSTOM_MAVEN_SETTINGS}" ] ; then echo "Using a custom Maven settings file" MVN_SETTINGS_FILE="${CUSTOM_MAVEN_SETTINGS}" @@ -115,7 +105,7 @@ if [[ "$DEBUG" ]] ; then fi LOCAL_CHECKOUT_ARG="" -if [ "${SHOULD_CHECKOUT}" -eq 1 ] && [ -z "${DO_NOT_OVERRIDE_PCT_CHECKOUT}" ] ; then +if [ "${SHOULD_CHECKOUT}" -eq 1 ] ; then ### # Checkout sources ### @@ -165,7 +155,7 @@ echo java ${JAVA_OPTS} ${extra_java_opts[@]} \ -reportFile ${PCT_OUTPUT_DIR}/pct-report.xml \ -workDirectory "${PCT_TMP}/work" ${WAR_PATH_OPT} \ -skipTestCache true \ - ${FAIL_ON_ERROR_ARG}\ + -failOnError \ ${LOCAL_CHECKOUT_ARG} \ -includePlugins "${ARTIFACT_ID}" \ -mvn "/usr/bin/mvn" \ From e5602b05ca435fa950a7d2b00844f7cd1e63a72c Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Wed, 3 Apr 2019 17:05:50 +0200 Subject: [PATCH 7/7] =?UTF-8?q?forgotten=20slash=20:facepalm:=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c07c3e67d..9f3973f73 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,7 +69,7 @@ node('docker') { stage("Run known successful case(s)") { sh '''docker run --rm \ - -v $(pwd)/jenkins.war:/pct/jenkins.war:ro + -v $(pwd)/jenkins.war:/pct/jenkins.war:ro \ -v $(pwd)/out:/pct/out -e JDK_VERSION=11 \ -e ARTIFACT_ID=buildtriggerbadge -e VERSION=buildtriggerbadge-2.10 \ jenkins/pct