Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-53581

Folders- provide info, groovy, how to get permissions

    XMLWordPrintable

Details

    Description

      Hi, just a question (I did not found another place where to ask)

      Is there any possibility how to obtain permissions for the folder job?

      I need something like permitted user (with permission level in ideal case) for the folder in jenkins

      I tried this:

      import com.cloudbees.hudson.plugins.folder.*
      import groovyjarjarasm.asm.Item
      import jenkins.model.Jenkins
      import 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 I cannot understand it fully, and this script returns 

       

      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'

       

      I am using following, but it should not matters

      Can you advise how to get it, or where to put my question? 
      Thanks in advance

       note

      Attachments

        Activity

          pavenova Pavel Novak created issue -
          pavenova Pavel Novak made changes -
          Field Original Value New Value
          Environment Jenkins ver. 2.121.2
          Jenkins ver. 2.107.3
          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
          pavenova Pavel Novak made changes -
          Description Hi, just a question (I did not found another place where to ask)

          Is there any possibility how to obtain permissions for the folder job?

          I need something like permitted user (with permission level in ideal case) for the folder in jenkins

          I tried this:

           
          {code:java}
          import com.cloudbees.hudson.plugins.folder.*
          import groovyjarjarasm.asm.Item
          import jenkins.model.Jenkins
          import 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
           AbstractProject proj = Hudson.instance.getItem(it.fullName)
           AuthorizationMatrixProperty authProperty = proj.getProperties(AuthorizationMatrixProperty.class)
           }
           }
          {code}
          But I cannot understand it fully, and this script returns 

           
          {code:java}
          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'{code}
           

          I am using following, but it should not matters
          |[Matrix Authorization Strategy Plugin|http://wiki.jenkins-ci.org/display/JENKINS/Matrix+Authorization+Strategy+Plugin] |

          Can you advise how to get it, or where to put my question? 
          Thanks in advance

           
          Hi, just a question (I did not found another place where to ask)

          Is there any possibility how to obtain permissions for the folder job?

          I need something like permitted user (with permission level in ideal case) for the folder in jenkins

          I tried this:

           
          {code:java}
          import com.cloudbees.hudson.plugins.folder.*
          import groovyjarjarasm.asm.Item
          import jenkins.model.Jenkins
          import 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)
               }
           }
          {code}
          But I cannot understand it fully, and this script returns 

           
          {code:java}
          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'{code}
           

          I am using following, but it should not matters
          |[Matrix Authorization Strategy Plugin|http://wiki.jenkins-ci.org/display/JENKINS/Matrix+Authorization+Strategy+Plugin] |

          Can you advise how to get it, or where to put my question? 
           Thanks in advance

           
          pavenova Pavel Novak made changes -
          Description Hi, just a question (I did not found another place where to ask)

          Is there any possibility how to obtain permissions for the folder job?

          I need something like permitted user (with permission level in ideal case) for the folder in jenkins

          I tried this:

           
          {code:java}
          import com.cloudbees.hudson.plugins.folder.*
          import groovyjarjarasm.asm.Item
          import jenkins.model.Jenkins
          import 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)
               }
           }
          {code}
          But I cannot understand it fully, and this script returns 

           
          {code:java}
          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'{code}
           

          I am using following, but it should not matters
          |[Matrix Authorization Strategy Plugin|http://wiki.jenkins-ci.org/display/JENKINS/Matrix+Authorization+Strategy+Plugin] |

          Can you advise how to get it, or where to put my question? 
           Thanks in advance

           
          Hi, just a question (I did not found another place where to ask)

          Is there any possibility how to obtain permissions for the folder job?

          I need something like permitted user (with permission level in ideal case) for the folder in jenkins

          I tried this:
          {code:java}
          import com.cloudbees.hudson.plugins.folder.*
          import groovyjarjarasm.asm.Item
          import jenkins.model.Jenkins
          import 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)
               }
           }
          {code}
          But I cannot understand it fully, and this script returns 

           
          {code:java}
          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'{code}
           

          I am using following, but it should not matters
          |[Matrix Authorization Strategy Plugin|http://wiki.jenkins-ci.org/display/JENKINS/Matrix+Authorization+Strategy+Plugin] |

          Can you advise how to get it, or where to put my question? 
           Thanks in advance

           note
           * if I am correct, javadoc for cloudbee's folder class is
            https://javadoc.jenkins.io/plugin/cloudbees-folder/com/cloudbees/hudson/plugins/folder/Folder.html
          dnusbaum Devin Nusbaum made changes -
          Resolution Not A Defect [ 7 ]
          Status Open [ 1 ] Closed [ 6 ]

          People

            dnusbaum Devin Nusbaum
            pavenova Pavel Novak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: