Job inheritance in Jenkins jobs

12,571

Solution 1

I would like to point out to you the release of a plugin that my team has developed and only recently published under open source. It implements full "Inheritance between jobs".

Here for further links that might help you:

Solution 2

I had pretty much the same problem. We have a set of jobs that needs to run for our trunk as well as at least two branches. The branches represent our versions, and a new branch is created every few months. Creating new jobs by hand for this is no solution, so I checked out some possibilities.

One possibility is to use the template plugin. This lets you create a hierarchy of jobs of a kind. It provides inheritance for builders, publishers and SCM settings. Might work for some, for me it was not enough.

Second thing I checked out was the Ant Script for job cloning, and his sibling the Bash Script. These are truly great. The idea is to make the script create a new job for, copy all settings from a template job, make changes as you need them. As this is a script it is very flexible and you can do a lot with that. Only drawback is, that this will not result in a real hierarchy, so changes in the template job will not reflect on jobs already cloned, only on jobs that will be created going forward.

Looking at the drawbacks and virtues of those two solutions, a combination of both might work best. You create a template project with some basic settings that will be true for all jobs, and then use a bash or ant script to create jobs depending on that template.

Hope that helps.

Solution 3

EZ Templates plugin allows you to use any job as a template for other jobs. It is really awesome. All you need is to set the base job as a template:

enter image description here

* Usually you would also disable the base job (like "abstract class").

Then create a new job, set it to use the base job template, and save: enter image description here

Now edit the new job - it will include everything! (and you can override existing configurations).

Note: There's another plugin Template Project for configuration templates, but it was not updated recently (last commit on 2016).

Solution 4

I was asked what our eventual solution to the problem was... After many months of fighting with our purchasing system we spent around $4000 US on Quickbuild. In a about 2-3 months we had a templated build system in place and were very happy with it. Before I left the company we had several product groups in the system and were automating the release process as well.

Quickbuild was a great product. It should be in the $40k class but it's priced at much less. While I'm sure Jenkins could do this, it would be a bit of a kludge whereas Quickbuild had this functionality baked in. I've implemented complex behaviors on top of products before (e.g. merge tracking in SVN 1.0) and regretted it. Quickbuild was reasonably priced and provided a solid base for our build and test systems.

At present, I'm at a firm using Bamboo and hope its new feature branch feature will provide much of what Quickbuild can do

Share:
12,571
Peter Kahn
Author by

Peter Kahn

Release engineer who actually enjoys release engineering. Trying to get the right information to the right people in the right way so they can do their jobs better. Presently happily employed with the excellent ZWS team at Zscaler. The team is rock solid, the product a rocket ship. We are hiring, and I'm not looking to get off this ride.

Updated on June 06, 2022

Comments

  • Peter Kahn
    Peter Kahn almost 2 years

    How do you handle mapping Jenkins jobs to your build process, and have you been able to build in cascading configurations on inheritance?

    For any given build I'll have at least three jobs (standard continuous integration/nightly, security scan, coverage) and then some downstream integration testing jobs. The configuration slicer plugin handles some aspects cross jobs but each jobs is still very much its own individual entity with no relationship to the other jobs in its group.

    I recently saw QuickBuild and it has job inheritance where a parent jobs can define a standard group of steps and its children can override and specialize. With Jenkins, I have copies of jobs, which is fine until I need to change something. With QuickBuild the relationship between jobs allows me to spread my changes with little effort.

    I've been trying to figure out how to handle this in Jenkins. I could use the parameterized build trigger plugin to allow jobs to call others and override aspects. I'd then harvest the data from the called jobs to its caller. I suspect I'll run into a series of problems where there are aspects which I can't override which will force me to implement Jenkins functionality in my own script thus making Jenkins less useful.

    How do you handle complexity in your build jobs in Jenkins? Have you heard of any serious problems with QuickBuild?

  • Mark
    Mark about 11 years
    The Template Plugin is the way to go. We've been using it and it's accomplished all we really wanted out of a templating plugin!
  • Harald Nordgren
    Harald Nordgren over 7 years
    Are there plans to continue the development? Especially fixing the listed incompatibilities with Job Config History and Artifactory. The last commit on GitHub is from Feb 2015.
  • Noam Manos
    Noam Manos over 3 years