From 01ac7c27eb4d080c51833ccdb4bfe4ceedc1232b Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 17 Sep 2019 16:52:53 -0700 Subject: [PATCH] Test propagation of additional downstream result types --- .../BuildTriggerStep/help-propagate.html | 3 ++- .../steps/build/BuildTriggerStepTest.java | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/resources/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStep/help-propagate.html b/src/main/resources/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStep/help-propagate.html index 056d0172..15af1d23 100644 --- a/src/main/resources/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStep/help-propagate.html +++ b/src/main/resources/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStep/help-propagate.html @@ -1,5 +1,6 @@

- If enabled (default state), then if the downstream build is anything but successful (blue ball), this step fails. + If enabled (default state), then the result of this step is that of the downstream build (e.g., + success, unstable, failure, not built, or aborted). If disabled, then this step succeeds even if the downstream build is unstable, failed, etc.; use the result property of the return value as needed.

diff --git a/src/test/java/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStepTest.java b/src/test/java/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStepTest.java index 97d9c57e..45f2deae 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStepTest.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStepTest.java @@ -189,17 +189,25 @@ public void abortBuild() throws Exception { } @Issue("JENKINS-49073") - @Test public void downstreamUnstable() throws Exception { - FreeStyleProject ds = j.createFreeStyleProject("ds"); + @Test public void downstreamResult() throws Exception { + downstreamResult(Result.SUCCESS); + downstreamResult(Result.UNSTABLE); + downstreamResult(Result.FAILURE); + downstreamResult(Result.NOT_BUILT); + downstreamResult(Result.ABORTED); + } + + private void downstreamResult(Result result) throws Exception { + FreeStyleProject ds = j.createFreeStyleProject(); ds.getBuildersList().add(new TestBuilder() { @Override public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { - build.setResult(Result.UNSTABLE); + build.setResult(result); return true; } }); - WorkflowJob us = j.createProject(WorkflowJob.class, "us"); - us.setDefinition(new CpsFlowDefinition("build 'ds'", true)); - j.assertBuildStatus(Result.UNSTABLE, us.scheduleBuild2(0)); + WorkflowJob us = j.createProject(WorkflowJob.class); + us.setDefinition(new CpsFlowDefinition(String.format("build '%s'", ds.getName()), true)); + j.assertBuildStatus(result, us.scheduleBuild2(0)); } @Test