Reputation: 11723
I have a set of jobs which only differ in the branch they build, and in a few other properties. The jobs have a reasonably complicated build script, so I would like to avoid having to maintain multiple copies of that script.
One possible way to avoid the redundant configuration is to set up one main job with the build script, and to trigger that job with different parameters from other jobs. However that approach has the following disadvantages:
So my question is: Instead of triggering the main job, is it possible to execute the main job "inline" in the triggering job?
E.g. it would be good if the console output of the main job would be directly printed in the console of the triggering job. Also, the main job should use the workspace of the triggering job (or a workspace in a sub-folder of the triggering job's workspace).
Upvotes: 2
Views: 2631
Reputation: 11723
The Template Project Plugin exactly provides the the functionality I was looking for.
It provides a build step "Execute builders from another project" which allows to execute the build steps of other jobs as they were configured in the triggering job.
This is awesome: I can now "extract methods" from my build jobs (into new "template" jobs) and plug them together as needed.
Upvotes: 3
Reputation: 625
I had similar manageability problems with a Hudson instance that was running 500+ build jobs - it was impractical to manually maintain that many jobs using the gui. However, you can provision jobs in Jenkins and Hudson remotely and programatically by using the CLI - which is supplied as a jar file [https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI].
I wrapped this in python and created an XML file from which to hold the build configuration. This also provided the ability to 'reset' the CI instance back to a known configuration - handy if you suspect build failures were caused by manually changes in the UI or if you are using a different CI server for each environment you deploy to (ie dev, test, prod) and need to provision a new one.
If you used this approach you could write code to generate the XML file and the provision your instance. I believe this is a robust approach as you can then also keep your CI configuration your revision control system.
Although this isn't a simple solution, I can't find or name a plugin that does what you are asking - which does present the opportunity for you to write one.
Upvotes: 0