In Jenkins, we can create many users but all the users must be managed by a centralized system, which is called Jenkins User Manage...
In Jenkins, we can create many users but all the users must be managed by a centralized system, which is called Jenkins User Management. In Jenkins initially, we are creating the admin user, which has all the privileges to run the jobs and we are not assigning any particular roles to the admin users. But the other users need to restrict so we need to assign the roles. To manage the roles we need role-based strategy management, so in Jenkins, we have “Role-based strategy plugin".
The Role-based strategy plugin is a special kind of plugin in Jenkins that is based on the role-based mechanism and allows us to manage users' permission. The features of this plugin are as follows below.
1. Creating global roles, such as admin, job creator, anonymous, etc., allowing to set Overall, Agent, Job, Run, View, and SCM permissions on a global basis.
2. Creating the project roles, allowing to set only Job and Run permissions on a project basis.
3. Creating the agent roles, allowing to set node-related permissions.
4. Assigning these roles to users and user groups
5. Roles can be assigned to users and user groups with the help of this plugin.
The Role-based Strategy plugin gives us permission to assign roles as well as give privileges to users. How to Install and use the Role-Based Strategy plugins in Jenkins?
The Role Strategy plugin can be installed from any Jenkins installation connected to the Internet using the Plugin Manager screen.
To Install a plugin in Jenkins go to Manage Jenkins → Manage Plugins
Click on the Available tab and Search the text "role" in the search box. As soon as the "Role-based Authorization Strategy" plugin will appear, click on the checkbox against it.
Click on the "Install without restart" button. We can also choose/select the "Download now and install after restart" button.
If suppose you got the error like restart the jenkins to activate the plugins. You can restart the jenkins service from the server.
To Activate the Role-Based Strategy by using the standard Manage Jenkins > Manage Global Security
Inside the configure Global Security scroll down you can able to see the Authorization.
In the Authorization already chosen anyone can do anything. Now we need to choose a Role-Based Strategy to take effect the role-based authentication.
Jenkins User Creations:
Now we need to create the Jenkins user to assign the roles for the particular user.
To create the Jenkins user Click Manage Jenkins → Manage Users
Manage Roles for the user:
To manage the Roles for the user we need to click jenkins Dashboard→ Manage Jenkins → Manage and assign roles
Now we can able to see the options like manage roles, Assign roles, Role Strategy Macros
Click the manage roles, It will show the existing roles, now we need to create a new role.
For us we are going to create the role for the developer, so I am creating the role as developer and clicking add
After Adding the user to the Global roles we need to choose the role.
For our part, we created the Developer role and already we have an admin role, now we need to choose this particular user to use which role.
I am choosing a Techeiv user. so it needs to use the Developer role. Click the save button.
Now we need to validate the role for the user. For that, we need to log in the jenkins using the newly created username and password
It will take you to the jenkins dashboard. For the Developer role, we are not permitting them to create the job, so we are trying to create the new jenkins job
After clicking the ok button it will show the error because we don't have the access to create the job.