Can't say I fully understand the intricacies if your matrices, but I think I can help you with your actual question
"I can easily write a shell script to spit out the mapping, but I can't work out how to invoke it when Jenkins is working out what it needs to copy"
The Archive the artifacts and Copy artifacts from another project post-build actions can take java style wildcards, like module/dist/**/*.zip
as well as environment variables/parameters, like ${PARAM}
for the list or artifacts. You can use commas ,
to add more artifacts.
The on-page help for Copy artifacts from another project states how to copy artifacts of a specific matrix configuration: To copy from a particular configuration, enter JOBNAME/AXIS=VALUE
, this is for the Project Name
attribute. That project name
attribute can also contain params as ${PARAM}
So, in your BAR job, have a Copy Artifacts build step, with Project Name
being FOO/X=${mymapping}
. What this will do is: every time a configuration of BAR
is run, it will copy artifacts only from FOO
with configuration of X=${mymapping}
.
Now you need to set the value of ${mymapping}
dynamically every time BAR
is run. A simple script like this may do the trick:
[[ ${Y:0:7} == "WINDOWS" ]] && mymapping=WINDOWS || mymapping=LINUX
Finally, you need to use EnvInject plugin to make this variable available to the rest of the build steps, including the Copy Artifacts step.
So, every time BAR
configuration runs, it will look at its own configuration axis Y
, and if that axis starts with WINDOWS
, it will set the ${mymapping}
to WINDOWS
, else set it to LINUX
. This ${mymapping}
is then made available to the rest of the build steps. When Copy Artifacts
build step is executed, it will only copy artifacts from FOO
where the X
axis matches ${mymapping}
(i.e. either WINDOWS
or LINUX
).
Full Setup
- Install EnvInject plugin.
- In BAR job configuration, tick
Prepare an environment for the run
(part of EnvInject plugin). - Make sure both checkboxes for keeping existing variables are checked.
- In
Script Content
copy your script:
[[ ${Y:0:7} == "WINDOWS" ]] && mymapping=WINDOWS || mymapping=LINUX
- Under Build steps, configure Copy Artifacts build step.
- Set Project name parameter to
FOO/X=${mymapping}
- Configure the rest as usual.