Skip to content

Commit

Permalink
Merge pull request #7 from fredg02/master
Browse files Browse the repository at this point in the history
merged tivv's pull request and adapted test for [JENKINS-11828]
  • Loading branch information
fredg02 committed Nov 28, 2011
2 parents 6ff97e6 + 901ba64 commit 4fb9dba
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Expand Up @@ -46,7 +46,6 @@
import hudson.model.Hudson;
import hudson.model.Job;
import hudson.model.Item;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.Project;
import hudson.model.Run;
import hudson.model.TaskListener;
Expand Down
Expand Up @@ -25,10 +25,7 @@

import hudson.Extension;
import hudson.FilePath;
import hudson.model.Hudson;
import java.io.File;
import java.io.IOException;
import java.net.URL;

/**
* Default implementation of CopyMethod extension point,
Expand Down
Expand Up @@ -27,6 +27,7 @@
import hudson.Extension;
import hudson.matrix.MatrixConfiguration;
import hudson.matrix.MatrixRun;
import hudson.model.Result;
import hudson.model.Descriptor;
import hudson.model.Cause;
import hudson.model.Cause.UpstreamCause;
Expand Down Expand Up @@ -73,7 +74,7 @@ public Run<?,?> getBuild(Job<?,?> job, EnvVars env, BuildFilter filter, Run<?,?>

@Override
protected boolean isSelectable(Run<?,?> run, EnvVars env) {
return isFallbackToLastSuccessful();
return isFallbackToLastSuccessful() && run.getResult().isBetterOrEqualTo(Result.SUCCESS);
}

@Extension(ordinal=25)
Expand Down
Expand Up @@ -65,6 +65,7 @@
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.CaptureEnvironmentBuilder;
import org.jvnet.hudson.test.FailureBuilder;
import org.jvnet.hudson.test.UnstableBuilder;
import org.jvnet.hudson.test.recipes.LocalData;

Expand Down Expand Up @@ -504,6 +505,12 @@ public void testTriggeredBuildSelector() throws Exception {
// Verify error if build not triggered by upstream job:
assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0, new UserCause()).get());
// test fallback

//run a failing build to make sure the fallback selects the last successful build
other.getPublishersList().clear();
other.getBuildersList().add(new FailureBuilder());
assertBuildStatus(Result.FAILURE, other.scheduleBuild2(0, new UserCause()).get());

p.getBuildersList().remove(CopyArtifact.class);
p.getBuildersList().add(new CopyArtifact(other.getName(),
new TriggeredBuildSelector(true), "*.txt", "", false, false));
Expand Down

0 comments on commit 4fb9dba

Please sign in to comment.