JenkinsFile SandBox error raised if the pipeline definition uses Enumerations:

      Caused by: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified staticMethod package.EnumX $INIT java.lang.String java.lang.Integer
      

          [JENKINS-33023] Enums are not supported in sandbox

          Flávio Augusto Valones created issue -
          Flávio Augusto Valones made changes -
          Link New: This issue is related to JENKINS-25119 [ JENKINS-25119 ]
          Flávio Augusto Valones made changes -
          Labels Original: script workflow New: workflow
          Flávio Augusto Valones made changes -
          Labels Original: workflow New: multibranch workflow
          Jesse Glick made changes -
          Labels Original: multibranch workflow New: groovy workflow
          Summary Original: Enums are Not supported in JenkinsFile SandBox New: Enums are not supported in sandbox

          Magnus Reftel added a comment -

          It's not quite as simple as enums not working at all. The following pipeline works fine on one installation (tested with Jenkins ver. 1.651.1 on Java 1.8.0_77-b03 with script-security 1.18.1) but fails with "RejectedAccessException: unclassified staticMethod Thing $INIT java.lang.String java.lang.Integer java.lang.String" on another (tested with Jenkins ver. 2.0 on both 1.8.0_31-b13 and 1.8.0_91-b14, and script-security 1.18.1):

          enum Thing {
            FIRST("The first thing"),
            SECOND("The second thing");
          
            String description;
          
            public Thing(String description) {
              this.description = description;
            }
          }
          
          node {
            for (int i = 0; i < Thing.values().length; i++) {
              Thing thing = Thing.values()[i];
              echo "${thing.description}"
            }
          }
          

          Magnus Reftel added a comment - It's not quite as simple as enums not working at all. The following pipeline works fine on one installation (tested with Jenkins ver. 1.651.1 on Java 1.8.0_77-b03 with script-security 1.18.1) but fails with "RejectedAccessException: unclassified staticMethod Thing $INIT java.lang.String java.lang.Integer java.lang.String" on another (tested with Jenkins ver. 2.0 on both 1.8.0_31-b13 and 1.8.0_91-b14, and script-security 1.18.1): enum Thing { FIRST( "The first thing" ), SECOND( "The second thing" ); String description; public Thing( String description) { this .description = description; } } node { for ( int i = 0; i < Thing.values().length; i++) { Thing thing = Thing.values()[i]; echo "${thing.description}" } }

          Magnus Reftel added a comment -

          Magnus Reftel added a comment - PR at https://github.com/jenkinsci/script-security-plugin/pull/58/commits/cb5b5cc21cfa8999903bcbcfd988bfcba35a79f7
          Magnus Reftel made changes -
          Assignee Original: Jesse Glick [ jglick ] New: Magnus Reftel [ magnusr ]
          Magnus Reftel made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          krzyk added a comment - - edited

          Same thing happens with Strings:

          Caused by: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified staticMethod Build $INIT java.lang.String java.lang.Integer
          

          I think this happens on call to this function:

          def commitHash() {
              sh 'git rev-parse HEAD > GIT_COMMIT'
              return readFile('GIT_COMMIT').trim()
          }
          

          krzyk added a comment - - edited Same thing happens with Strings: Caused by: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified staticMethod Build $INIT java.lang. String java.lang. Integer I think this happens on call to this function: def commitHash() { sh 'git rev-parse HEAD > GIT_COMMIT' return readFile( 'GIT_COMMIT' ).trim() }

            Unassigned Unassigned
            valones Flávio Augusto Valones
            Votes:
            4 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: