Create and Manage Users in Jenkins
Generally, in a large organization, there are multiple separate teams to run and manage jobs in Jenkins. But managing this crowd of users and assigning roles to them is too difficult.
By default, when you create a user in Jenkins, it can access almost everything. In this, you can create multiple users but can only assign the same global roles and privileges to them. This is not ideal, especially for large organizations.
To enable you to assign different roles and privileges to different users in Jenkins, you should have to install the Role Strategy Plugin.
Install Role-based Authorization Strategy Plugin
Step 1: Open your Jenkins dashboard by visiting http://localhost:8080/jenkins
Steps 2: Click on ‘Manage Jenkins‘ and select the ‘Available‘ tab.
Step 3: On the filter option, type “role-based” and press Enter.
Step 4: Now, select the plugin and click on ‘Install without restart‘ button.
Step 5: Click on ‘Go back to the top page‘.
Enable Role-Based Strategy on Jenkins
Step 1: After Plugin installation, go to the ‘Manage Jenkins’ and then click on ‘Configure Global Security‘.
When you click the Configure Global Security option then you will see the following page:
Check on Enable security option.
Step 2: On the Security Realm section, select ‘jenkins’ own user database‘.
- On Authorization section, select ‘Role-Based Strategy‘.
Click on Save.
Step 3: You will be prompted to add your first user. Here, we are setting up an admin user for the system.
Click on Create First Admin User.
Creating User on Jenkins
Step 1: Now it’s time to setup your users in the system. When you go to manage Jenkins and scroll down, you will see the ‘Manage Users‘ option. Click on this option.
Step 2: Just Like, you defined the admin user, and start creating other users for the system. Let’s create another user:
- To create another user click on ‘Create User’ option on the left hand side of the Manage Users page.
- Click on Create User button.
Managing User Roles on Jenkins
Step 1:
- Click on Manage Jenkins.
- Select Manage and Assign Roles. Note that, Manage and Assign Role will only be visible if you have installed the Role strategy plugin.
Step 2: Click on Manage Roles option to add new roles.
Step 2: To create a new role called “developer”.
- Type “developer” in the Role to add option.
- Click on Add to create a new role.
- Now, select the appropriate permissions that you want to assign to the developer role.
- Then Click on Save button.
Assigning User Roles on Jenkins
Step 1: Now, you have created roles, let’s assign them to specific users.
- Click on Manage Jenkins.
- Then select Manage and Assign Roles.
- Click on Assign Roles.
Step 2: Let’s add new role “developer” to user.
- Add the User name on User/group to add option.
- Click on Add button.
- Select “developer” role check box.
- You can assign any role to any user as per your requirement.
- Then click on Save.