Skip to content

Commit

Permalink
[JENKINS-18220] Diagnostics.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Jul 18, 2013
1 parent 45273c9 commit 129ce34
Showing 1 changed file with 19 additions and 3 deletions.
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit 129ce34

Please sign in to comment.