19

In Jenkins I have two different projects and two users I want to authorize:

User1 can only view, build, deploy Project1.

User2 can only view, build, deploy Project2.

I have installed role based plugin, but am unable to get it working. Please help.

2

3 Answers 3

26

I agree Project Based could solve your problem but it would create headache on administrator if going forward you have 100 users. Then For each user you have to give permissions,which will be a lot of effort and for those who are facing issues with Role based plugin. Here is the solution:-

Step 1:- click on Global configuration under Manage Jenkins.

Step 2:- click on radio button "Role-Based Strategy" and save.

Step 3:- Go to Manage and Assign Roles under Manage Jenkins.

Step 4:- select Manage Roles.

Step 5:- You will see somewhat similar image as

manage role

Step 6:- Now add a global role part from admin under "role to add" option and grant Read Permission only.Shown in Blue color

For eg:- Employee in this case

Step 7:- For the above question and below example some assumptions

Test = Project1
check = Project2

Under Project roles:-

 Role to add:-developer

 Pattern:-Test

This means developer will be able to view only Project "Test".

Pattern is basically your project name.You can use regular expressions also here. For eg:- Pattern:- Tes* then all projects beginning with Tes will have role as developer.

Similarly Add role as tester and Pattern as check,shown under black box,Tester will be able to view only Project "check"

Step 8:- Give the respective permissions view,build etc by check boxes and click on save.

Step 9:- Now go back to Manage Roles and select assign role and you will find something similar to this.

assign role

Step 10:- Under Global role add user1 and user2 and check box on to Employee as their role as shown in in the image above in black box.

[NOTE]Every New User/Group has to be added here and given the role of employee or admin.

Step 11:- Under Project Role,

Add user1 and user2 and assign them tester and developer role. As shown in green color.

Click on save.

[NOTE]

Developer will be able to view only Project "Test"
tester will be able to view only  Project "check"
3
  • Thanks @Triangle.It's really very useful for me. Oct 5, 2015 at 10:56
  • there are user groups for 100-s of users.
    – Zloj
    Nov 25, 2015 at 21:15
  • Yes, there may or may NOT exist user groups. Leave 100 even if you take 10 new user for each Project1 and Project2 in the above question , Matrix Authorization Strategy Plugin it would be time consuming for the Admin because the roles are already mentioned in the question which was a one time job at the starting.
    – Triangle
    Nov 26, 2015 at 3:47
9

Matrix Authorization Strategy Plugin is the best option for your case. Very flexible configuration - both global and per project. You'll want to check in the 'Enable project-based security' option in project configuration ( the check box is close to the top of the job's config page ) and then add users/groups for which you want to configure the access permissions. After that use check boxes to set/remove permissions.

4
  • 1
    Good plugin choice, but there is no documentation :( Aug 20, 2015 at 7:59
  • @Jan Lutenko ,hey I am not able to find 'Enable project-based security' ,are you talking about 'Enable securuty' check box that comes at top of Configure Global Security. I have checked it, but not able to authorize as per job basis. Aug 20, 2015 at 8:03
  • @ranjitchoudhary where are you trying to configure this? I assume you are configuring in Jenkins security/system config. You wanted it for a project right? Check project config page - it's there.
    – Zloj
    Aug 20, 2015 at 9:00
  • @michaelbahr it is very self-explaining IMHO
    – Zloj
    Aug 20, 2015 at 9:00
0

Finally I solved it, Go to Configure Global Security In Security Realm : select Jenkins’ own user database and Allow users to sign up. then select Project-based Matrix Authorization Strategy . add users with authorization: Overall Read and Job Read. Now save.

Now Create project and in Configuration select Enable project-based security. and add that user to whom you want to provide authorization. For details you can refer: http://www.tothenew.com/blog/jenkins-implementing-project-based-matrix-authorization-strategy/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.