Here is a more general groovy script; it uses the groovy plugin and copyArtifact plugin; see instructions in code comments.
It simply copies artifacts from all downstream jobs to the upstream workspace.
If you call the same task several times, you can use the task number in the copyAtifact 'target' parameter to save artifacts separately.
// This script copies artifacts from downstream jobs into the upstream job workspace. // // To use, add a "Execute system groovy script" build step into the upstream job // after the invocation of other projects/jobs, and specify // "/var/lib/jenkins/groovy/copyArtifactsFromDownstream.groovy" as script. import hudson.plugins.copyartifact.* import hudson.model.AbstractBuild import hudson.Launcher import hudson.model.BuildListener import hudson.FilePath for (subBuild in build.builders) { println(subBuild.jobName + " => " + subBuild.buildNumber) copyTriggeredResults(subBuild.jobName, Integer.toString(subBuild.buildNumber)) } // Inspired by http://kevinormbrek.blogspot.com/2013/11/using-copy-artifact-plugin-in-system.html def copyTriggeredResults(projName, buildNumber) { def selector = new SpecificBuildSelector(buildNumber) // CopyArtifact(String projectName, String parameters, BuildSelector selector, // String filter, String target, boolean flatten, boolean optional) def copyArtifact = new CopyArtifact(projName, "", selector, "**", null, false, true) // use reflection because direct call invokes deprecated method // perform(Build<?, ?> build, Launcher launcher, BuildListener listener) def perform = copyArtifact.class.getMethod("perform", AbstractBuild, Launcher, BuildListener) perform.invoke(copyArtifact, build, launcher, listener) }
source share