Get list of users who has access to a project role

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Get list of users who has access to a project role

tlnarayana

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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Get list of users who has access to a project role

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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Get list of users who has access to a project role

gotviseryon
@Victor - Excuse me here.  I'm kind of new to this stuff.  Could you please brief on how to use this groovy script?

On Monday, November 19, 2018 at 7:33:57 AM UTC-5, Victor Martinez wrote:
Might <a href="https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/export-role-strategy-permissions-to-csv.groovy" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fjenkins-scripts%2Fblob%2Fmaster%2Fscriptler%2Fexport-role-strategy-permissions-to-csv.groovy\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHF_Vw7y65Qe4i__ryc3vh_eeJjxg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fjenkins-scripts%2Fblob%2Fmaster%2Fscriptler%2Fexport-role-strategy-permissions-to-csv.groovy\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHF_Vw7y65Qe4i__ryc3vh_eeJjxg&#39;;return true;">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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Get list of users who has access to a project role

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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Get list of users who has access to a project role

tlnarayana
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 wrote:
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?
  • <a onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FScriptler%2BPlugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmQy9flwxF4FO-x1a2rm5eFaaWdg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FScriptler%2BPlugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmQy9flwxF4FO-x1a2rm5eFaaWdg&#39;;return true;" href="https://wiki.jenkins.io/display/JENKINS/Scriptler+Plugin" target="_blank" rel="nofollow">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 <a onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRole%2BStrategy%2BPlugin%23RoleStrategyPlugin-Version2.9.0(Aug27%2C2018)\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHDuZeddMvvhZa5fGa2xMexwsmkow&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRole%2BStrategy%2BPlugin%23RoleStrategyPlugin-Version2.9.0(Aug27%2C2018)\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHDuZeddMvvhZa5fGa2xMexwsmkow&#39;;return true;" href="https://wiki.jenkins.io/display/JENKINS/Role+Strategy+Plugin#RoleStrategyPlugin-Version2.9.0(Aug27,2018)" target="_blank" rel="nofollow">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 [hidden email].
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.