From a8eb43868ee430b8c65b94d8f7972b3b43f887fb Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Mon, 27 Jan 2020 15:02:09 +0000 Subject: [PATCH 01/16] Add pipeline-model-definition plugin --- bom-latest/pom.xml | 56 +++++++++++++++++ sample-plugin/pom.xml | 5 ++ .../bom/sample/DeclarativePipelineTest.java | 60 +++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 sample-plugin/src/test/java/io/jenkins/tools/bom/sample/DeclarativePipelineTest.java diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index a31cb43bb..6c70f167d 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -11,6 +11,7 @@ 1.41 4.3.0 + 1.6.0 2.6.3 1.20 2.40 @@ -78,6 +79,11 @@ workflow-job 2.39 + + org.jenkins-ci.plugins.workflow + workflow-multibranch + 2.16 + org.jenkins-ci.plugins.workflow workflow-scm-step @@ -115,6 +121,11 @@ apache-httpcomponents-client-4-api 4.5.10-2.0 + + org.jenkins-ci.plugins + authentication-tokens + 1.4 + org.jenkins-ci.plugins branch-api @@ -145,6 +156,16 @@ display-url-api 2.3.2 + + org.jenkins-ci.plugins + docker-commons + 1.14 + + + org.jenkins-ci.plugins + docker-workflow + 1.22 + org.jenkins-ci.plugins durable-task @@ -171,6 +192,11 @@ git-server 1.9 + + org.jenkins-ci.plugins + jackson2-api + 2.10.2 + org.jenkins-ci.plugins jdk-tool @@ -216,6 +242,11 @@ pipeline-input-step 2.11 + + org.jenkins-ci.plugins + pipeline-stage-step + 2.3 + org.jenkins-ci.plugins plain-credentials @@ -282,6 +313,31 @@ jquery-detached 1.2.1 + + org.jenkinsci.plugins + pipeline-model-api + ${pipeline-model-definition-plugin.version} + + + org.jenkinsci.plugins + pipeline-model-declarative-agent + 1.1.1 + + + org.jenkinsci.plugins + pipeline-model-definition + ${pipeline-model-definition-plugin.version} + + + org.jenkinsci.plugins + pipeline-model-extensions + ${pipeline-model-definition-plugin.version} + + + org.jenkinsci.plugins + pipeline-stage-tags-metadata + ${pipeline-model-definition-plugin.version} + org.jenkins-ci diff --git a/sample-plugin/pom.xml b/sample-plugin/pom.xml index 068585526..fcb848148 100644 --- a/sample-plugin/pom.xml +++ b/sample-plugin/pom.xml @@ -186,6 +186,11 @@ pipeline-input-step test + + org.jenkinsci.plugins + pipeline-model-definition + test + org.jenkins-ci.plugins timestamper diff --git a/sample-plugin/src/test/java/io/jenkins/tools/bom/sample/DeclarativePipelineTest.java b/sample-plugin/src/test/java/io/jenkins/tools/bom/sample/DeclarativePipelineTest.java new file mode 100644 index 000000000..31e7ef853 --- /dev/null +++ b/sample-plugin/src/test/java/io/jenkins/tools/bom/sample/DeclarativePipelineTest.java @@ -0,0 +1,60 @@ +package io.jenkins.tools.bom.sample; + +import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; +import org.jenkinsci.plugins.workflow.job.WorkflowJob; +import org.jenkinsci.plugins.workflow.job.WorkflowRun; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.jvnet.hudson.test.BuildWatcher; +import org.jvnet.hudson.test.JenkinsRule; + +public class DeclarativePipelineTest { + @ClassRule + public static BuildWatcher buildWatcher = new BuildWatcher(); + + @Rule + public JenkinsRule r = new JenkinsRule(); + + @Test + public void smokes() throws Exception { + final WorkflowRun run = runPipeline(m( + "pipeline {", + " agent none", + " stages {", + " stage('Example') {", + " steps {", + " echo 'Hello world'", + " }", + " }", + " }", + "}")); + + r.assertBuildStatusSuccess(run); + r.assertLogContains("Hello world", run); + } + + /** + * Run a pipeline job synchronously. + * + * @param definition the pipeline job definition + * @return the started job + */ + private WorkflowRun runPipeline(String definition) throws Exception { + final WorkflowJob project = r.createProject(WorkflowJob.class, "example"); + project.setDefinition(new CpsFlowDefinition(definition, true)); + final WorkflowRun workflowRun = project.scheduleBuild2(0).waitForStart(); + r.waitForCompletion(workflowRun); + return workflowRun; + } + + /** + * Approximates a multiline string in Java. + * + * @param lines the lines to concatenate with a newline separator + * @return the concatenated multiline string + */ + private static String m(String... lines) { + return String.join("\n", lines); + } +} From 1c7f014e1355e86b5f09caafd68048a990f33ced Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Wed, 24 Jun 2020 12:10:11 +0100 Subject: [PATCH 02/16] Bump pipeline-model-definition to 1.7.0, remove docker deps --- bom-latest/pom.xml | 17 +---------------- sample-plugin/pom.xml | 5 +++++ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index 6c70f167d..1c6010e80 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -11,7 +11,7 @@ 1.41 4.3.0 - 1.6.0 + 1.7.0 2.6.3 1.20 2.40 @@ -121,11 +121,6 @@ apache-httpcomponents-client-4-api 4.5.10-2.0 - - org.jenkins-ci.plugins - authentication-tokens - 1.4 - org.jenkins-ci.plugins branch-api @@ -156,16 +151,6 @@ display-url-api 2.3.2 - - org.jenkins-ci.plugins - docker-commons - 1.14 - - - org.jenkins-ci.plugins - docker-workflow - 1.22 - org.jenkins-ci.plugins durable-task diff --git a/sample-plugin/pom.xml b/sample-plugin/pom.xml index fcb848148..eafb9c853 100644 --- a/sample-plugin/pom.xml +++ b/sample-plugin/pom.xml @@ -191,6 +191,11 @@ pipeline-model-definition test + + org.jenkinsci.plugins + pipeline-model-declarative-agent + test + org.jenkins-ci.plugins timestamper From 02bb058543a3662fde80c9a656a9894bf5f16a01 Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Thu, 25 Jun 2020 10:36:49 +0100 Subject: [PATCH 03/16] fixes --- bom-latest/pom.xml | 16 ++++++++++++---- sample-plugin/pom.xml | 5 ----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index 1c6010e80..8ee1313e0 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -18,6 +18,7 @@ 2.80 2.22 3.5 + 2.16 @@ -82,7 +83,13 @@ org.jenkins-ci.plugins.workflow workflow-multibranch - 2.16 + ${workflow-multibranch.version} + + + org.jenkins-ci.plugins.workflow + workflow-multibranch + tests + ${workflow-multibranch.version} org.jenkins-ci.plugins.workflow @@ -230,7 +237,7 @@ org.jenkins-ci.plugins pipeline-stage-step - 2.3 + 2.4 org.jenkins-ci.plugins @@ -305,12 +312,13 @@ org.jenkinsci.plugins - pipeline-model-declarative-agent - 1.1.1 + pipeline-model-definition + ${pipeline-model-definition-plugin.version} org.jenkinsci.plugins pipeline-model-definition + tests ${pipeline-model-definition-plugin.version} diff --git a/sample-plugin/pom.xml b/sample-plugin/pom.xml index eafb9c853..fcb848148 100644 --- a/sample-plugin/pom.xml +++ b/sample-plugin/pom.xml @@ -191,11 +191,6 @@ pipeline-model-definition test - - org.jenkinsci.plugins - pipeline-model-declarative-agent - test - org.jenkins-ci.plugins timestamper From 165f6d7daad69039630393ce8cb0ca004360b1b5 Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Thu, 25 Jun 2020 17:17:41 +0100 Subject: [PATCH 04/16] Use pipeline-stage-step 2.5 Co-authored-by: Jesse Glick --- bom-latest/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index 8ee1313e0..e0db491fa 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -237,7 +237,7 @@ org.jenkins-ci.plugins pipeline-stage-step - 2.4 + 2.5 org.jenkins-ci.plugins From 6b68069c8e5fbc3eb61dba0b8103712e4493cbe3 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 25 Jun 2020 18:56:30 -0400 Subject: [PATCH 05/16] Turn off failFast while all remaining test failures are diagnosed --- failFast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/failFast b/failFast index 27ba77dda..c508d5366 100644 --- a/failFast +++ b/failFast @@ -1 +1 @@ -true +false From c7bb746aa53504fc78b70fd04ce0d66f4b3302fd Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Wed, 8 Jul 2020 10:11:43 +0100 Subject: [PATCH 06/16] Use jackson2-api 2.11.0 Co-authored-by: Tim Jacomb --- bom-latest/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index 06bdfd677..dd2393c9e 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -187,7 +187,7 @@ org.jenkins-ci.plugins jackson2-api - 2.10.2 + 2.11.0 org.jenkins-ci.plugins From f3ea6d8ddfc63e55d0a324c7954c5d14583a31e1 Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Thu, 9 Jul 2020 10:19:44 +0100 Subject: [PATCH 07/16] Revert "Use jackson2-api 2.11.0" This reverts commit c7bb746aa53504fc78b70fd04ce0d66f4b3302fd. --- bom-latest/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index dd2393c9e..06bdfd677 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -187,7 +187,7 @@ org.jenkins-ci.plugins jackson2-api - 2.11.0 + 2.10.2 org.jenkins-ci.plugins From 3dbad5ca130d77e7c2e6a4a645dbffebe0df023d Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Thu, 9 Jul 2020 10:22:12 +0100 Subject: [PATCH 08/16] Use branch-api 2.5.7 --- bom-latest/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index 06bdfd677..ead2e23b2 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -131,7 +131,7 @@ org.jenkins-ci.plugins branch-api - 2.5.6 + 2.5.7 org.jenkins-ci.plugins From 9c93910c5fefe008450352ad513aa010842dee45 Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Mon, 13 Jul 2020 17:44:35 +0100 Subject: [PATCH 09/16] Catch up to master, start from pipeline-model-definition plus minimal extras --- bom-latest/pom.xml | 27 +++++++++++++++++---------- sample-plugin/pom.xml | 6 ++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index ead2e23b2..fe8ff06b7 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -11,14 +11,15 @@ 1.41 4.3.0 - 1.7.0 + 1.7.1 2.6.3 1.20 2.40 - 2.80 + 2.81 + 2.39 + 2.16 2.22 3.5 - 2.16 @@ -78,18 +79,24 @@ org.jenkins-ci.plugins.workflow workflow-job - 2.39 + ${workflow-job-plugin.version} + + + org.jenkins-ci.plugins.workflow + workflow-job + tests + ${workflow-job-plugin.version} org.jenkins-ci.plugins.workflow workflow-multibranch - ${workflow-multibranch.version} + ${workflow-multibranch-plugin.version} org.jenkins-ci.plugins.workflow workflow-multibranch tests - ${workflow-multibranch.version} + ${workflow-multibranch-plugin.version} org.jenkins-ci.plugins.workflow @@ -146,7 +153,7 @@ org.jenkins-ci.plugins credentials - 2.3.10 + 2.3.11 org.jenkins-ci.plugins @@ -177,7 +184,7 @@ org.jenkins-ci.plugins git-client - 3.3.0 + 3.3.1 org.jenkins-ci.plugins @@ -242,7 +249,7 @@ org.jenkins-ci.plugins plain-credentials - 1.6 + 1.7 org.jenkins-ci.plugins @@ -258,7 +265,7 @@ org.jenkins-ci.plugins script-security - 1.73 + 1.74 org.jenkins-ci.plugins diff --git a/sample-plugin/pom.xml b/sample-plugin/pom.xml index fcb848148..443009a5c 100644 --- a/sample-plugin/pom.xml +++ b/sample-plugin/pom.xml @@ -103,6 +103,12 @@ workflow-job test + + org.jenkins-ci.plugins.workflow + workflow-job + tests + test + org.jenkins-ci.plugins.workflow workflow-step-api From fdae3eb4755f6de471c9821725c7cc13027c9391 Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Mon, 20 Jul 2020 12:09:03 +0100 Subject: [PATCH 10/16] Use branch-api 2.5.8 --- bom-latest/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index 69cf18935..d39ab2ee9 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -138,7 +138,7 @@ org.jenkins-ci.plugins branch-api - 2.5.7 + 2.5.8 org.jenkins-ci.plugins From b489a73013bc9b77743f225ae7225a0735105ea4 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 20 Jul 2020 12:12:58 -0400 Subject: [PATCH 11/16] Trying to make sure PCT failures always result in an unstable status. https://github.com/jenkinsci/bom/pull/179#discussion_r457514174 Unfortunately TEST_FAILURES only asserts that surefire:test did not succeed, but does not verify that it even ran to begin with: https://github.com/jenkinsci/plugin-compat-tester/blob/c502ba1cc6ebf39b9525e914fc537c38918ed535/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java#L322-L323 --- pct.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pct.sh b/pct.sh index f04cc1db2..d773bbf20 100755 --- a/pct.sh +++ b/pct.sh @@ -34,6 +34,25 @@ then echo PCT failed cat pct-report.xml exit 1 +elif grep -q -F -e 'TEST_FAILURES' pct-report.xml +then + echo PCT test failures, making sure at least one is reported + candidates= + for t in pct-work/*/target + do + if [ \! -d $t/surefire-reports ] + then + candidates="$candidates $t" + fi + done + mkdir -p pct-work/target/surefire-reports + cat > pct-work/target/surefire-reports/TEST-pct.xml < + + + + +EOF fi # TODO rather than removing all these, have a text file of known failures and just convert them to “skipped” From 91fdadd382e6d2127acf3396cd8e9ceb1e270290 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 20 Jul 2020 14:39:14 -0400 Subject: [PATCH 12/16] b489a73 was improperly marking plugins failed due to known test failures --- pct.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pct.sh b/pct.sh index d773bbf20..37c2891e7 100755 --- a/pct.sh +++ b/pct.sh @@ -36,23 +36,21 @@ then exit 1 elif grep -q -F -e 'TEST_FAILURES' pct-report.xml then - echo PCT test failures, making sure at least one is reported - candidates= - for t in pct-work/*/target + echo PCT marked failed, checking to see if that is due to a failure to run tests at all + for t in pct-work/*/{,*/}target do - if [ \! -d $t/surefire-reports ] + if [ -f $t/test-classes/the.hpl -a \! -d $t/surefire-reports ] then - candidates="$candidates $t" - fi - done - mkdir -p pct-work/target/surefire-reports - cat > pct-work/target/surefire-reports/TEST-pct.xml < $t/surefire-reports/TEST-pct.xml <<'EOF' - + EOF + fi + done fi # TODO rather than removing all these, have a text file of known failures and just convert them to “skipped” From 97a69380c77399b896bf215ae0fddd6f46447e5f Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 20 Jul 2020 15:45:45 -0400 Subject: [PATCH 13/16] Still not right; if Surefire starts to run but then the VM crashes, will leave no test files behind; really better for PCT to set -Dmaven.test.failure.ignore (cherry picked from commit 7c271c3d1f0cec03e9db026af982425199fdbe1d) --- pct.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pct.sh b/pct.sh index 37c2891e7..e3c9b5dcd 100755 --- a/pct.sh +++ b/pct.sh @@ -39,9 +39,9 @@ then echo PCT marked failed, checking to see if that is due to a failure to run tests at all for t in pct-work/*/{,*/}target do - if [ -f $t/test-classes/the.hpl -a \! -d $t/surefire-reports ] + if [ -f $t/test-classes/InjectedTest.class -a \! -f $t/surefire-reports/TEST-InjectedTest.xml ] then - mkdir $t/surefire-reports + mkdir -p $t/surefire-reports cat > $t/surefire-reports/TEST-pct.xml <<'EOF' From 862b01eaadf56ed9688b1d012a5b456006705334 Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Wed, 30 Sep 2020 15:23:23 +0100 Subject: [PATCH 14/16] Use ExampleStep in declarative pipeline test, reinstate failfast --- failFast | 2 +- .../io/jenkins/tools/bom/sample/DeclarativePipelineTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/failFast b/failFast index c508d5366..27ba77dda 100644 --- a/failFast +++ b/failFast @@ -1 +1 @@ -false +true diff --git a/sample-plugin/src/test/java/io/jenkins/tools/bom/sample/DeclarativePipelineTest.java b/sample-plugin/src/test/java/io/jenkins/tools/bom/sample/DeclarativePipelineTest.java index 31e7ef853..86356d679 100644 --- a/sample-plugin/src/test/java/io/jenkins/tools/bom/sample/DeclarativePipelineTest.java +++ b/sample-plugin/src/test/java/io/jenkins/tools/bom/sample/DeclarativePipelineTest.java @@ -24,14 +24,14 @@ public void smokes() throws Exception { " stages {", " stage('Example') {", " steps {", - " echo 'Hello world'", + " example(x: 'foobar')", " }", " }", " }", "}")); r.assertBuildStatusSuccess(run); - r.assertLogContains("Hello world", run); + r.assertLogContains("Ran on foobar!", run); } /** From 32499c410ecbc88214fe19bc7201c30dbcbdd41d Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Wed, 30 Sep 2020 16:46:38 +0100 Subject: [PATCH 15/16] Bump pipeline-model-definition to 1.7.2 --- bom-latest/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom-latest/pom.xml b/bom-latest/pom.xml index 2ef711423..02e669669 100644 --- a/bom-latest/pom.xml +++ b/bom-latest/pom.xml @@ -11,7 +11,7 @@ 1.43 4.3.0 - 1.7.1 + 1.7.2 2.6.3 1.20 2.40 From bd36b6b2748130d92abafa60e8d52ad826fb07c9 Mon Sep 17 00:00:00 2001 From: Chris Kilding <590569+chriskilding@users.noreply.github.com> Date: Wed, 30 Sep 2020 16:51:27 +0100 Subject: [PATCH 16/16] Rebuild