Skip to content

Commit

Permalink
[FIXED JENKINS-10214] use MatrixBuild.getExactRuns when available (co…
Browse files Browse the repository at this point in the history
…re 1.413+)

to copy artifacts just from matrix configs that were run on that build
  • Loading branch information
alanharder committed Jul 24, 2011
1 parent 56098dc commit ceb1ae2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
Expand Up @@ -33,6 +33,7 @@
import hudson.diagnosis.OldDataMonitor;
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixProject;
import hudson.matrix.MatrixRun;
import hudson.maven.MavenModuleSet;
import hudson.maven.MavenModuleSetBuild;
import hudson.model.AbstractBuild;
Expand Down Expand Up @@ -190,7 +191,7 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
} else if (run instanceof MatrixBuild) {
boolean ok = false;
// Copy artifacts from all configurations of this matrix build
for (Run r : ((MatrixBuild)run).getRuns())
for (Run r : getMatrixRuns((MatrixBuild)run))
// Use subdir of targetDir with configuration name (like "jdk=java6u20")
ok |= perform(r, expandedFilter, targetDir.child(r.getParent().getName()),
baseTargetDir, copier, console);
Expand Down Expand Up @@ -235,6 +236,16 @@ private boolean perform(Run run, String expandedFilter, FilePath targetDir,
return cnt > 0 || isOptional();
}

// TODO: remove this method and use getExactRuns directly once minimum core is 1.413+
private static List<MatrixRun> getMatrixRuns(MatrixBuild build) {
// Use MatrixBuild.getExactRuns if available
try {
return (List<MatrixRun>)build.getClass().getMethod("getExactRuns").invoke(build);
} catch (Exception ignore) {}

return build.getRuns();
}

// Find the job from the given name; usually just a Hudson.getItemByFullName lookup,
// but this class encapsulates additional logic like filtering on parameters.
private static class JobResolver {
Expand Down

0 comments on commit ceb1ae2

Please sign in to comment.