The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing


External Resources

More Info

Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Default Queuing

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-Mocha-Webdriverio and 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. 

  1. Add a node by clicking Manage Jenkins in the admin page menu, then click Manage Nodes > Add New Node.
  2. Add configuration information such as a name for the node and the number of executors for it to use. 
  3. In the Labels field, enter a label like sauceJobs.
  4. Navigate to the configuration pages for the jobs that you want to run on this node and select the General tab.
  5. Select the option Restrict where this project can be run.
  6. 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.