Hi, 
regarding https://issues.jenkins-ci.org/browse/JENKINS-53581  
<https://issues.jenkins-ci.org/browse/JENKINS-53581>

I would like to get permissions setup for the folders in the Jenkins by *groovy 
script *used in the jenkins script console 

Environment:
Jenkins ver. 2.121.2 
 + Folders plugin 6.5.1 
 + Matrix Authorization Strategy 2.3 

Jenkins ver. 2.107.3 
 + Folders plugin 6.4 
 + Matrix Authorization Strategy 2.2

I am using similar scripts for kind of reporting, e.g. number of folders, 
folders with recent builds (in given period, etc.)

I tried, with the clues over the internet, following 

import com.cloudbees.hudson.plugins.folder.*import 
groovyjarjarasm.asm.Itemimport jenkins.model.Jenkinsimport 
hudson.security.*import hudson.model.*//AbstractProject proj = 
Hudson.instance.getItem("YourJob")//AuthorizationMatrixProperty authProperty = 
proj.getProperty(AuthorizationMatrixProperty.class)
 def items=Jenkins.instance.getAllItems();//load all items in jenkins  
items.each{
      //get folders only      if(it instanceof Folder){
      // println it //print for debug     AbstractProject proj = 
Hudson.instance.getItem(it.fullName)
     AuthorizationMatrixProperty authProperty =  
proj.getProperties(AuthorizationMatrixProperty.class)
     }
 }


But that fails because casting error 

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast 
object 'com.cloudbees.hudson.plugins.folder.Folder@4c019d3f[foldername]' with 
class 'com.cloudbees.hudson.plugins.folder.Folder' to class 
'hudson.model.AbstractProject'




In the link above I got an advise as to use abstract folder, etc. now I am in 
the state I am getting error about getting property 

groovy.lang.MissingMethodException: No signature of method: 
com.cloudbees.hudson.plugins.folder.Folder.getProperties() is applicable for 
argument types: (java.lang.Class) values: [class 
hudson.security.AuthorizationMatrixProperty]
Possible solutions: getProperties(), getProperties()


Do you have any idea, how to obtain the permissions on the folder 
- in fact, 1st level like "job root" should be enough, I dont need to go deeper
- in ideal case I would like to get all the granted permissions
- at least, I need users, which are having any permissions on the folder (Excl. 
jenkins admins, ofc.)

note- I am jenkins admin, so I have the full permissions

Thanks in advance for any advise.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/05145b85-3688-4937-9fce-7f318f38e2c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to