Bringing Order to Your Jenkins Jobs
Join the DZone community and get the full member experience.
Join For FreeOnce you’ve been working with Jenkins and uberSVN
for a while, you may find yourself in a situation where you have
several jobs that need to run in a specific order, for example:
- Job 1 and Job 3 can run simultaneously.
- BUT Job 2 should only start when Job 1 and Job 3 have finished running.
- AND Job 4 should only start when Job 2 has finished.
How can you implement this complicated setup? This is where Jenkins’ ‘Advanced Project Options’ and build triggers come in handy. In this tutorial, we’ll walk through the different options for scheduling jobs using Jenkins and uberSVN, the free ALM platform for Apache Subversion.
Note, this tutorial assumes you have already created a job and configured it to automatically poll your Subversion repository.
1) Open the Jenkins tab of your uberSVN installation and select a job.
2) Click the ‘Configure’ option from the left-hand menu.
3) In the ‘Advanced Project Options’ tab, select the ‘Advanced…’ button
4) This contains two options that are useful for ordering your jobs:
- Block build when upstream project is building – blocks builds when a
dependency is in the queue, or building. Note, these dependencies
include both direct and transitive dependencies.
- Block build when downstream project is building – blocks builds when
a child of the project is in the queue, or building. This applies to
both direct and transitive children.
If this option doesn’t meet your needs, you can explicitly name a project (or projects) that must be built before your job is allowed to run. To set this:
1) Scroll down to the ‘Build triggers’ tab on the configure page.
2) Select the ‘Build after other projects are built’ checkbox. This will bring up a text box where you can list any number of projects.
Utilized properly, the build triggers and advanced project options should allow you to organize your jobs into a schedule. Tip, if you need even more control over your build schedule, there are plenty of scheduling plugins available. To add plugins to Jenkins, simply:
1) Open the ‘Manage Jenkins’ screen.
2) Click the ‘Manage Plugins’ link.
3) Open the ‘Available’ tab and select the appropriate plugins from the list.
Published at DZone with permission of Jessica Thornsby, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments