Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a build number within the MultiJob plugin?

The MultiJob plugin is great and I want to use it for my build process, but there is one issue I have to solve before: There are three jobs A, B and C. SVN triggers job A and B (parallel execution) and job C starts when A and B have finished. Job C requires the artifacts from job A and B as an input.

          -> Job A (with A.zip) 
Trigger                          -> Job C (use artifacts A.zip and B.zip)
          -> Job B (with B.zip)

To design the workflow with the MultiJob plugin is easy, but I have no clue how to get the corresponding artifacts from job A and B in job C. Can I pass the build numbers to job C (buildNr(A) != buildNr(B))? Or is there a smarter way to solve the issue?

like image 740
Sascha Vetter Avatar asked Apr 17 '13 13:04

Sascha Vetter


2 Answers

The multijob plugin sets the following environment variables per job (code):

  • <JOBNAME>_BUILD_NUMBER
  • <JOBNAME>_BUILD_RESULT

Where JOBNAME is created by the name of the job with all non characters and numbers replaced with _. Thus you can pass the build numbers as parameters to Job C:

configuration of job C with Jenkins MultiJob plugin

like image 66
jack_kerouac Avatar answered Nov 12 '22 00:11

jack_kerouac


There's a workaround using EnvInject and a groovy script: https://issues.jenkins-ci.org/browse/JENKINS-20241

like image 21
mmaruska Avatar answered Nov 11 '22 22:11

mmaruska