Certified Jenkins Engineer
Jenkins Administration and Monitoring Part 1
Demo Job Restrictions
In this tutorial, you’ll learn how to use the Job Restrictions plugin in Jenkins to control which jobs can run on specific nodes. By leveraging job names, users, and logical operators, you can enforce security policies and prevent unintended builds.
Table of Contents
- Install the Job Restrictions Plugin
- Configure Node-Level Restrictions
2.1 Navigate to the Built-In Node
2.2 Enable Job Restrictions - Test the Restriction
3.1 Building an Unmatched Job
3.2 Creating a Matching Job - Add User-Based Restrictions
- Links and References
1. Install the Job Restrictions Plugin
- Go to Manage Jenkins › Manage Plugins.
- Under the Available tab, search for Job Restrictions.
- Select the plugin and click Install without restart.
- Once the installation completes, choose Restart Jenkins when installation is complete and no jobs are running.
Note
Ensure your Jenkins instance is at least version 2.387 or higher for full compatibility with the Job Restrictions plugin.
After Jenkins restarts, the plugin is ready for configuration.
2. Configure Node-Level Restrictions
2.1 Navigate to the Built-In Node
- From the Jenkins dashboard, click Manage Jenkins › Manage Nodes and Clouds.
- Select the built-in node (often labeled “built-in”).
2.2 Enable Job Restrictions
- Click Configure on the built-in node.
- Scroll to Node Properties and check Job Restrictions.
- Click Add and select Regular Expression — Job Name.
- Enter a regex pattern that matches the jobs you want to allow. For example:
^Dasher_.*
Use Add again to combine rules with AND, OR, or NOT logic.
Common Restriction Types
Restriction Type | Purpose | Example Pattern |
---|---|---|
Regular Expression — Job Name | Permit jobs matching a name pattern | ^Dasher_.* |
Started by User | Allow builds initiated by specific users | Emma |
Parameterized Job | Restrict based on parameter values | env=production |
3. Test the Restriction
3.1 Building an Unmatched Job
Attempt to build a job that does not match your regex—for example, npm-version-test. It will stay in the queue as Pending.
Warning
Jobs that don’t meet any restriction rules will remain queued indefinitely. Monitor the queue to avoid resource bottlenecks.
3.2 Creating a Matching Job
From the dashboard, click New Item.
Enter Dasher_testJob and select Freestyle project.
In Build steps, add a shell step:
echo "Hello"
Click Save, then Build Now. This job matches the pattern and will execute.
4. Add User-Based Restrictions
To grant specific users the ability to run any job on this node:
- Navigate back to Manage Jenkins › Manage Nodes and Clouds › built-in node › Configure.
- Under Job Restrictions, click Add › Started by User.
- Enter the username (e.g.,
Emma
). - Set the logical operator to OR so that jobs match either the regex rule or the user rule.
- Click Save.
Now, user Emma can trigger any job on this node, while all other users must use the Dasher_
prefix.
Links and References
With regex-based rules, user filters, and logical operators, you can precisely control job execution across your Jenkins nodes.
Watch Video
Watch video content