- Platform Configurator
- Getting Started with Selenium for Automated Website Testing
- Getting Started with Appium for Mobile Native Application Testing
- Selenium Bootcamp by Dave Haeffner
- Appium Bootcamp by Dave Haeffner and Matthew Edwards
One of the most helpful features of Jenkins CI is automatic queuing of jobs. On a given Jenkins instance, if there are more build jobs requested than there are resources to execute these jobs, the jobs will queue, and Jenkins will handle executing these jobs in the order they were requested. By assigning labels to nodes, you can specify the resources you want to use for specific jobs, and set up graceful queuing of all the jobs for your test runs. This topic will explain how queuing works in Jenkins, and how to set up your nodes and jobs to use labels. It assumes you have access to an admin user account in Jenkins, or at least a user with appropriate administrative rights.
Table of Contents
Let’s look at a basic example of how queuing works on Jenkins.
This screenshot shows the administration page for a basic Jenkins instance with a single master node, which is a machine that runs jobs.
The Build Queue and Build Executor Status panels show the capacity of this node for running jobs. This node has two executors, which means up to two jobs can be executed on this Jenkins instance at a time. If three jobs are started, then the first two started will execute and the third one will be added to the Build Queue, as shown in this screenshot
In this example, the jobs
Josh-JS-Karma jobs were started first and were assigned an executor, and the
Josh-AddressBook-TestNG job has been queued and is waiting for an executor assignment. Once an executor is available after a job has finished, the third job will be assigned to it and run.
Adding and Labeling Nodes for Resource Assignment
Adding multiple nodes on Jenkins is straightforward. This allows multiple nodes to be used for multiple OSs/platforms, load balancing jobs, and other functions. When you add a label to a node, you can restrict the running of specific jobs on that node.
- Add a node by clicking Manage Jenkins in the admin page menu, then click Manage Nodes > Add New Node.
- Add configuration information such as a name for the node and the number of executors for it to use.
- In the Labels field, enter a label like
- Navigate to the configuration pages for the jobs that you want to run on this node and select the General tab.
- Select the option Restrict where this project can be run.
- In the Label Expression field, enter the label for the node where you want the job to run.
If you want to add a label to an existing node, navigate to Manage Jenkins > Manage Nodes > <Select Node> > Configure, and add the label to the node. You can add labels to as many nodes as you want to use as resources for specific jobs.
Once you have configured your jobs to run on specific nodes, they will queue to run on that node based on the number of available executors, as described in the example.