Introduction
The Role-Based Access Control plugin introduces several new concepts to Jenkins when enabled/installed. As these concepts and terms are used in a lot of different systems other than Jenkins, this section defines their meaning within the Role-Based Access Control plugin. Let’s see how to setup Role based plugin in Jenkins step by step.
Step 1 - Go to Jenkins dashboard and click on the "Manage Jenkins " link, as highlighted below:
Step 2 - As soon as we will click on Manage Jenkins, we will be redirected to the Manage Jenkins Page.
Now, click on the "Manage Users" under the Security section on the Manage Jenkins page.
Step 3 - As soon as we click on "Manage Users" under the Security section on the Manage Jenkins page, we will be redirected to the Users page.
We can create a new user by clicking on the "Create User" link as highlighted above.
Step 4 - As soon as we will click on the Create User link, we will be redirected to the Create User page on which we need to fill in the username, password, confirm password, Full name, and email address information.
After filling in all information, click on the Create User button.
Step 5 - As soon as we click on the Create User button, a new user will be created and displayed on the Manage Users page.
So, in this way, we can create as many as users in Jenkins. Now, let's see how we can assign roles to these users?
How to manage user roles in Jenkins?
Alright, so in this section, we will see how to create roles and assign permissions to users. For achieving this, follow the below steps:
Step 1 - Firstly, go to the Manage Jenkins page and click on "Manage and Assign Roles".
Note: This option will be visible only after installing the "Role-based strategy plugin".
As soon as, we will click on Manage and Assign Roles, we will be redirected to the Manage and Assign Roles page.
Step 2 - Secondly, click on the "Manage Roles" option, as highlighted below:
As soon as we click on the Manage Roles option, we will go to the Manage Roles page.
Step 3 - For creating new roles, kindly follow the below highlighted steps:
- Type the Role that we want to add in the "Role to add" textbox. Here, we are going to create a role named "developer".
- Click on the Add button.
- As soon as we will click on the Add button, the required role will be added to the Global roles grid.
So in this way, we can create as many roles as we want. Now it's time to permit the newly added role.
Step 4 - Check the permissions that we want to give to the newly added role and click on the Save button.
So, now we have a new role in the system and it has certain permissions associated with it. Now, let's see how we can assign these roles to a specific user, so that that user also gets the same permissions, as given to the mentioned role.
How to assign roles to a user in Jenkins?
In the previous section, we saw how to create roles and give permission to those roles. In this section, we will see how to assign those roles to the users. For demonstration purposes, we created one user on Jenkins. Kindly follow the below steps to assign the role to the specific user:
Step 1 - Go to the Manage and Assign Roles page and click on the "Assign Roles" link, as highlighted below:
Step 2 - As soon as we will click on Assign Roles, we will go to the Assign Roles page. Here, under the Global roles section, we can see the new role ("developer") that we added in the previous section. Now we can assign this role to the respective user. Kindly do the following steps to achieve it:
- Type the user that we want to add in the "User/group to add" textbox. Here, we are going to add a user named "toolsqadev".
- Click on the Add button.
- As soon as we will click on the Add button, the required user will add to the Global roles grid. Now, check the developer checkbox against this user.
- Click on the Save button.
Summary
After completing all the steps you will achieve roles-based strategy implementation in Jenkins via Role, Item Role/Project. Only specific project-wise user role can have access to specific project.
Note: Please share your input/query with me in comment box if required any help.