By default, Jenkins comes with very basic user creation options. You can create multiple users but can only assign the same global roles and privileges to them. This not ideal, especially for a large organization.
The Role Strategy Plugin enable you to assign different roles and privileges to different users**.** You will first need to install the plugin in your Jenkins mange environment.
Step 1) Login to your Jenkins dashboard by visiting http://localhost:8080/ (in this case the Jenkins Instance i am running is in my local system)
Step 2)
- Under Manage Jenkins, Click Create User
- Enter User details like password, name, email etc.
- Click Create User
Now you have a User with different id and password , but now how to assign them different permissions and access of different project . So for it Jenkins give us a plugin (Role Strategy Plugin)
There are two methods for installing plugins in Jenkins:
-
Installing it through your Jenkins dashboard
-
Downloading the plugin from Jenkins website and installing it manually.
So lets walk through the easy process of installing it via Jenkins dashboard
Here is the Pictorial presentation of how to add a Plugin to your project
Now once you have installed the Plugin
Click on Go back to the top page. Till now we Authorisation strategy as Legacy mode , Now we have to change it to Role Based Strategy So , for doing that
Go to Manage Jenkins -> Configure Global Security -> Under Authorization, select Role Based Strategy. Click on Save.
In this step, we shall learn to certain roles to a single user or a group of users.
Step 1)
-
Go to Manage Jenkins
-
Select Manage and Assign Roles
Note: that the Manage and Assign Roles option will only be visible if you've installed the role strategy plugin.
Step 2) Click on Manage Roles to add new roles based on your organization.
Step 3) To create a new role called "developer",
- Type "developer" under "role".
- Click on "Add" to create a new role.
- Now, select the permissions you want to assign to the "Developer" role.
- Click Save
Step 1) Now that you have created roles, let us assign them to specific users.
- Go to Manage Jenkins
- Select Manage and Assign Roles
Step 2) We shall add the new role "developer" to user "the user that you made during the First Point"
- Selector developer role checkbox
- Click Save
You can assign any role to any user, as per your need.
You can create project specific roles under Project Roles.
In Jenkin's Manage and Assign Roles
- Enter a role as "tester"
- Add a pattern to this by adding test.*, so that any username starting with "test" will be assigned the project role you specify.
- Click Add
- Select privileges
- Click Save