Friday 5 July 2019

How to Create Users & Manage Permissions: Role Strategy Plugin

Generally, in a large organization, there are multiple, separate teams to manage and run jobs in Jenkins. But managing this crowd of users and assigning roles to them can prove troublesome.
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.
In this tutorial, you will learn
  • How to Create/Add a User
  • Install Role Strategy Plugin
  • Create Roles
  • Assign a Role
  • Project Roles

How to Create/Add a User

Step 1) Login to your Jenkins dashboard by visiting http://localhost:8080/
If you haven't installed Jenkins in your local server, go to the appropriate URL and access your dashboard by using your login credentials.
Step 2) You will now see options to create new users and manage current users.
Step 3)
  • Under Manage Jenkins, Click Create User
  • Enter User details like password, name, email etc.
  • Click Create User
Step 4) User is created

Install Role Strategy Plugin

There are two methods for installing plugins in Jenkins:
  1. Installing it through your Jenkins dashboard
  2. Downloading the plugin from Jenkins website and installing it manually.
Step 1)
1. Go to Manage Jenkins
2. Click on the Manage Plugins option
Step 2)
  1. In available section, screen Search for "role".
  2. Select Role-based Authorization Strategy plugin
  3. Click on "Install without restart" (make sure you have an active internet connection)
Step 3)
Once the plugin is installed, a "success" status will be displayed.
Click on Go back to the top page.
Step 4) Go to Manage Jenkins -> Configure Global Security -> Under Authorization, select Role Based Strategy. Click on Save.

Create Roles

In this step, we shall learn to certain roles to a single user or a group of users.
Step 1)
1. Go to Manage Jenkins
2. 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",
  1. Type "developer" under "role".
  2. Click on "Add" to create a new role.
  3. Now, select the permissions you want to assign to the "Developer" role.
  4. Click Save

Assign a Role

Step 1) Now that you have created roles, let us assign them to specific users.
  1. Go to Manage Jenkins
  2. Select Manage and Assign Roles
Step 2) We shall add the new role "developer" to user "guru99"
  1. Selector developer role checkbox
  2. Click Save
You can assign any role to any user, as per your need.

Project Roles

You can create project specific roles under Project Roles.
Step 1) In Jenkin's Manage and Assign Roles
  1. Enter a role as "tester"
  2. Add a pattern to this by adding tester.*, so that any username starting with "tester" will be assigned the project role you specify.
  3. Click Add
  4. Select privileges
  5. Click Save

No comments:

Post a Comment