Discussion:
Get list of users who has access to a project role
LnT
2018-11-19 11:54:14 UTC
Permalink
Hi -
requirement came up from the audit team , fetch list of users having access
to production environment Jenkins jobs.
Our Jenkins setup has predefined project roles and able to see the list of
users who has access to different environments. since the list of users are
dynamic and audit is required monthly. Instead fetching the user
information manually looking at Jenkins ,wish to write an automation script
.
Tried to access api url http://<<MyJenkinsURL>>/role-strategy/api/

Giving 404 Error. Does this mean , jenkins not provided API for urer roles?
Input is required, the best way to get this information - in writing the
script.

Precisely ,
List of Project Roles are
*PRD-JOB-READ*
*PRD-JOB-RUN*
*PRD-JOB-ADMIN*

Need to fetch the list of users who has access *PRD-JOB-RUN*. Could you
show somelight

Regards,
LnT
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f6b4b13d-1bca-4bfc-b245-9f2d3d9eec6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Victor Martinez
2018-11-19 12:33:56 UTC
Permalink
Might
https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/export-role-strategy-permissions-to-csv.groovy
provide those details?

Cheers
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c91bdcc4-c254-4339-bd72-c420b46e2a60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
g***@gmail.com
2018-11-19 14:14:34 UTC
Permalink
@Victor - Excuse me here. I'm kind of new to this stuff. Could you please
brief on how to use this groovy script?
Post by Victor Martinez
Might
https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/export-role-strategy-permissions-to-csv.groovy
provide those details?
Cheers
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/05efdafd-413e-4a34-a83c-6f7b4c21fbb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Victor Martinez
2018-11-19 19:24:16 UTC
Permalink
I have not executed that particular groovy script at all, but based on the
description and name I guess that's something you could use.

*How to use the groovy script?*

- https://wiki.jenkins.io/display/JENKINS/Scriptler+Plugin

That's one way to gather those details.

Besides that, I just went through the role-strategy api and found
https://wiki.jenkins.io/display/JENKINS/Role+Strategy+Plugin#RoleStrategyPlugin-Version2.9.0(Aug27,2018)
, I guess, that particular API url might work for your use case, although I
have not tried it

Cheers
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/200df9fb-1ec3-4461-be4c-af9988b929f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
LnT
2018-11-20 09:13:02 UTC
Permalink
Thanks to All,
I found workaround. Written python script, takes input of
*<Jenkins-home>/config.xml* , parse and get the users. Hope this will help
someone like me.

from xml.dom import minidom


xmldoc = minidom.parse(*'config.xml'*)

roleList = xmldoc.getElementsByTagName(*'role'*)

for role in roleList:

roleName = role.attributes[*'name'*].value

if roleName == *"prj_user_prd"*:

print *"roleName:"*,roleName

userList = role.getElementsByTagName(*"assignedSIDs"*)[0
].getElementsByTagName(*"sid"*)

break

for user in userList:

print user.firstChild.nodeValue


On Tuesday, November 20, 2018 at 12:54:17 AM UTC+5:30, Victor Martinez
Post by Victor Martinez
I have not executed that particular groovy script at all, but based on the
description and name I guess that's something you could use.
*How to use the groovy script?*
- https://wiki.jenkins.io/display/JENKINS/Scriptler+Plugin
That's one way to gather those details.
Besides that, I just went through the role-strategy api and found
https://wiki.jenkins.io/display/JENKINS/Role+Strategy+Plugin#RoleStrategyPlugin-Version2.9.0(Aug27,2018)
, I guess, that particular API url might work for your use case, although I
have not tried it
Cheers
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2530c0f3-50af-4628-ba2d-c9db0817daa4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...