Permalink
Browse files

[JENKINS-18220] Diagnostics.

  • Loading branch information...
jglick committed Jul 18, 2013
1 parent 45273c9 commit 129ce342d7207de3e87055dddb896ca0f4be1cfe
Showing with 19 additions and 3 deletions.
  1. +19 −3 src/main/java/hudson/plugins/copyartifact/SpecificBuildSelector.java
@@ -28,14 +28,19 @@
import hudson.model.Descriptor;
import hudson.model.Job;
import hudson.model.Run;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Copy artifacts from a specific build.
* @author Alan Harder
*/
public class SpecificBuildSelector extends BuildSelector {
private String buildNumber;

private static final Logger LOGGER = Logger.getLogger(SpecificBuildSelector.class.getName());

private final String buildNumber;

@DataBoundConstructor
public SpecificBuildSelector(String buildNumber) {
@@ -49,9 +54,20 @@ public String getBuildNumber() {
@Override
public Run<?,?> getBuild(Job<?,?> job, EnvVars env, BuildFilter filter, Run<?,?> parent) {
String num = env.expand(buildNumber);
if (num.startsWith("$")) return null; // unresolved variable, probably unset
if (num.startsWith("$")) {
LOGGER.log(Level.FINE, "unresolved variable {0}", num);
return null;
}
Run<?,?> run = job.getBuildByNumber(Integer.parseInt(num));
return (run != null && filter.isSelectable(run, env)) ? run : null;
if (run == null) {
LOGGER.log(Level.FINE, "no such build {0} in {1}", new Object[] {num, job.getFullName()});
return null;
}
if (!filter.isSelectable(run, env)) {
LOGGER.log(Level.FINE, "{0} claims {1} is not selectable", new Object[] {filter, run});
return null;
}
return run;
}

@Extension(ordinal=-10)

0 comments on commit 129ce34

Please sign in to comment.