Skip to content
Permalink
Browse files
[FIXED JENKINS-10214] use MatrixBuild.getExactRuns when available (co…
…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 ceb1ae26c08c759bc282d7417df028489ec072e5
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
@@ -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;
@@ -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);
@@ -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 {

0 comments on commit ceb1ae2

Please sign in to comment.