Skip to content
Permalink
Browse files

[FIXED JENKINS-28673] ISE after deleting a downstream build.

  • Loading branch information...
jglick committed May 18, 2016
1 parent a850c28 commit c869245bed52a6b0b9c35e9a38f4c6d3f843a1ff
@@ -7,6 +7,7 @@
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.listeners.RunListener;
import java.util.List;
import org.jenkinsci.plugins.workflow.steps.StepContext;

import java.util.logging.Logger;
@@ -37,14 +38,17 @@ public void onStarted(Run<?, ?> run, TaskListener listener) {
}

@Override
@SuppressWarnings("deprecation") // TODO Actionable offers no standard way of removing actions
public void onCompleted(Run<?,?> run, @Nonnull TaskListener listener) {
for (BuildTriggerAction action : run.getActions(BuildTriggerAction.class)) {
List<BuildTriggerAction> actions = run.getActions(BuildTriggerAction.class);
for (BuildTriggerAction action : actions) {
if (!action.isPropagate() || run.getResult() == Result.SUCCESS) {
action.getStepContext().onSuccess(new RunWrapper(run, false));
} else {
action.getStepContext().onFailure(new AbortException(run.getFullDisplayName() + " completed with status " + run.getResult() + " (propagate: false to ignore)"));
}
}
run.getActions().removeAll(actions);
}

@Override
@@ -69,9 +69,15 @@ public void evaluate() throws Throwable {
WorkflowRun r2 = foo.getLastBuild();
assertNotNull(r2);
story.j.assertBuildStatusSuccess(r2);
}
}
);
}
});

story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
story.j.jenkins.getItemByFullName("test1", FreeStyleProject.class).getBuildByNumber(1).delete();
}
});
}

private void assertFreeStyleProjectsInQueue(int count) {
@@ -39,12 +39,15 @@

@Issue("JENKINS-25851")
@Test public void buildTopLevelProject() throws Exception {
j.createFreeStyleProject("ds");
FreeStyleProject ds = j.createFreeStyleProject("ds");
WorkflowJob us = j.jenkins.createProject(WorkflowJob.class, "us");
us.setDefinition(new CpsFlowDefinition(
"def ds = build 'ds'\n" +
"echo \"ds.result=${ds.result} ds.number=${ds.number}\"", true));
j.assertLogContains("ds.result=SUCCESS ds.number=1", j.assertBuildStatusSuccess(us.scheduleBuild2(0)));
// TODO JENKINS-28673 assert no warnings, as in StartupTest.noWarnings
// (but first need to deal with `WARNING: Failed to instantiate optional component org.jenkinsci.plugins.workflow.steps.scm.SubversionStep$DescriptorImpl; skipping`)
ds.getBuildByNumber(1).delete();
}

@Issue("JENKINS-25851")
@@ -254,10 +257,12 @@ public void cancelBuildQueue() throws Exception {

@Issue("JENKINS-29169")
@Test public void buildVariablesWorkflow() throws Exception {
j.jenkins.createProject(WorkflowJob.class, "ds").setDefinition(new CpsFlowDefinition("env.RESULT = \"ds-${env.BUILD_NUMBER}\"", true));
WorkflowJob ds = j.jenkins.createProject(WorkflowJob.class, "ds");
ds.setDefinition(new CpsFlowDefinition("env.RESULT = \"ds-${env.BUILD_NUMBER}\"", true));
WorkflowJob us = j.jenkins.createProject(WorkflowJob.class, "us");
us.setDefinition(new CpsFlowDefinition("def vars = build('ds').buildVariables; echo \"received RESULT=${vars.RESULT} vs. BUILD_NUMBER=${vars.BUILD_NUMBER}\"", true));
j.assertLogContains("received RESULT=ds-1 vs. BUILD_NUMBER=null", j.assertBuildStatusSuccess(us.scheduleBuild2(0)));
ds.getBuildByNumber(1).delete();
}

@Issue("JENKINS-28063")

0 comments on commit c869245

Please sign in to comment.
You can’t perform that action at this time.