Bringing Order to Your Jenkins Jobs
- 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.
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.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)