hudson - Being clever when copying artifacts with Jenkins and multi-configurations -


suppose have (fictional) set of projects: foo , bar. both of these projects have sort of multi-configuration option.

foo has matrix on axis x takes values in { x1, ..., xn } (so there n builds of foo). bar has matrix on axis y takes values in { y1, ..., ym } (so there m builds of bar).

however, bar needs copy artifacts foo. turns out y strictly finer partition n. example, x might take values { windows, linux } , y might { windows_xp, windows_7, debian_testing, fedora } or whatever.

is possible bar sort of table lookup work out configuration of foo needs when copies artifacts across? can write shell script spit out mapping, can't work out how invoke when jenkins working out needs copy.

at moment, hacky solution have 2 axes on foo, on x , 1 y, , filter out combinations don't make sense. resulting combination filter ridiculous , matrix sparse. yuck.

a solution don't parametrise foo on y instead: huge waste of compile time. and, worse, generated artefacts pretty big, if did sort of caching, you'd still have keep unnecessary copies floating around.

can't understand intricacies if matrices, think can actual question

"i can write shell script spit out mapping, can't work out how invoke when jenkins working out needs copy"

the archive artifacts , copy artifacts project post-build actions can take java style wildcards, module/dist/**/*.zip environment variables/parameters, ${param} list or artifacts. can use commas , add more artifacts.

the on-page copy artifacts project states how copy artifacts of specific matrix configuration: to copy particular configuration, enter jobname/axis=value, project name attribute. project name attribute can contain params ${param}

so, in bar job, have copy artifacts build step, project name being foo/x=${mymapping}. is: every time configuration of bar run, copy artifacts foo configuration of x=${mymapping}.

now need set value of ${mymapping} dynamically every time bar run. simple script may trick:

[[ ${y:0:7} == "windows" ]] && mymapping=windows || mymapping=linux 

finally, need use envinject plugin make variable available rest of build steps, including copy artifacts step.

so, every time bar configuration runs, @ own configuration axis y, , if axis starts windows, set ${mymapping} windows, else set linux. ${mymapping} made available rest of build steps. when copy artifacts build step executed, copy artifacts foo x axis matches ${mymapping} (i.e. either windows or linux).

full setup

  • install envinject plugin.
  • in bar job configuration, tick prepare environment run (part of envinject plugin).
  • make sure both checkboxes keeping existing variables checked.
  • in script content copy script:
    [[ ${y:0:7} == "windows" ]] && mymapping=windows || mymapping=linux
  • under build steps, configure copy artifacts build step.
  • set project name parameter foo/x=${mymapping}
  • configure rest usual.

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -