How To Manage Users and Roles in Jenkins

Posted on 164 views

Can I create Roles in Jenkins server and assign to users?. The answer to this question is “Yes“. Jenkins is the leading open source automation server known to DevOps. Through hundreds of Plugins at your disposal, you can extend its features set to achieve ultimate building, automation, and deployment of any project.

How to manage users and roles in Jenkins

By default, when you create a user in Jenkins, it can access almost everything. In this guide, we will cover how you can create fine-grained roles for proper access control to Jenkins Server. We will use Roles Strategy Plugin to achieve this.

You need a running Jenkins Server to use this guide. If you stepped on this page while doing research work, below are the guides to help with installation of Jenkins server.

How to install Jenkins on CentOS 7

Running Jenkins Server in Docker Container with Systemd

How to Install and Configure Jenkins on Arch Linux

How to Install Jenkins on Ubuntu

Once Jenkins is live, login with the admin user account and navigate to Jenkins > Manage Jenkins > Manage Plugins > Available > Filter.

jenkins-users-roles-01

Type “Role-based Authorization Strategy” in the filter box and hit enter.

jenkins-users-roles-02-1024x247

Select plugin and click the “Download now and install after restart“.

jenkins-users-roles-04

Restart Jenkins by clicking on check box.

Enable Role-Based Strategy on Jenkins

After plugin installation, navigate to “Jenkins > Configure Global Security“. Tick Enable security and Role-Based Strategy then save settings.

jenkins-users-roles-05

Creating User Roles on Jenkins

Go to “Jenkins >  Manage and Assign Roles > Manage Roles“.

jenkins-users-roles-06

jenkins-users-roles-07

Provide role name to create on Role to add and click ‘Add“.

jenkins-users-roles-08-1024x100

Tick appropriate values for your new role, in my case, I’m creating view only user so it will have.

  • Read under Overall
  • All under View

jenkins-users-roles-09

You can also create “Project roles” which will work for all projects with that matches specified pattern.

jenkins-users-roles-10-1024x209

jenkins-users-roles-11-1024x217

Slave roles can also be created in a similar way.

Assign roles to users

Go to “Jenkins >  Manage and Assign Roles > Assign Roles“.

Login as user with assigned role. Only projects granted should be visible.

jenkins-users-roles-15-1024x327

For any new user created without being assigned a role, access denied message should be shown.

jenkins-users-roles-16-1024x181

If you want to learn more about Jenkins Administration checkout below

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.