Jenkins – Copying artifacts from multiple upstream jobs at join in Jenkins

Jenkinsjoin;

Is it possible to have a Jenkins Job with has been triggered by the Join plugin copy artifacts from multiple upstream jobs?

I'm trying to set-up a Jenkins configuration with a "diamond" of jobs: my-trigger runs and spawns two jobs, my-fork1 and my-fork2, that can run concurrently and take varying amounts of time, and the Join plugin sets off the job my-join once both forks have completed.

Each of my-trigger, my-fork1 and my-fork2 creates and fingerprints artifacts (say, text files).

I want to copy the artifacts from each of the upstream jobs in my-join using the "Copy artifacts from another project" tool, with the "Which build" parameter set to "Upstream build that triggered this job". However, I see output like this in the console of my-join:

Building remotely on build-machine in workspace /path/to/workspace/my-join

Copied 1 artifact from "my-trigger" build number 63

Copied 1 artifact from "my-fork1" build number 63

Unable to find a build for artifact copy from: my-fork2

and the job fails. In this case, my-fork2 finished first, so my-fork1 triggered the join step. I believe that that means that my-join only has record of my-fork1 and my-trigger as being upstream. If my-fork1 finishes first, then my-fork2 kicks off the join, and the job fails when trying to copy from my-fork1.

If I change the configuration to copy the artifact from the build "Latest successful build" then the build succeeds, but my-trigger may run many times in succession so there would be no guarantee that my-join is joining related artifacts.

How can I get the join step to copy artifacts from multiple forks upstream?

Note: the second point of this question seems to be asking the same thing, but the only answer there doesn't address it, and has been accepted.

Thanks
tensorproduct

Best Answer

If your builds are parameterized with a unique parameter for each run of the join-diamond, you can use that parameter in the CopyArtifact plugin to determine which build to copy from. You would want to specify "Latest successful build" and qualify it with the parameter and value.

We have a similar situation where I work; multiple simultaneous runs of a join-diamond. The parameter in the build allows the downstream jobs to get the correct artifacts from the upstream jobs.