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

Can't access "include" or "list" in parallel test executor. Security exceptions thrown.

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Critical Critical
    • None
    • Win2008 R2. Jenkins 2.49. Latest plugins.

      Jenkins throws security exceptions when trying to access "split.includes" or "split.list", as described in examples such as this.

      There's no apparent way around the exceptions and it's not clear how to make it work in other ways.

          [JENKINS-42801] Can't access "include" or "list" in parallel test executor. Security exceptions thrown.

          Jesse Glick added a comment -

          Works for me.

          Jesse Glick added a comment - Works for me.

          After updating Jenkins and some plugins to the current version today, I encounter this issue, too. I didn't change anything in my Jenkinsfile.

          Part of the stacktrace is:

          org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field java.lang.String list
              at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:397)

          Trying to debug this, i used this snipped inside my Jenkinsfile:

           

              def splits = splitTests parallelism: count(6)
              echo "Class of splits is ${splits.class}"
              for (int i = 0; i < splits.size(); i++) {
                def num = i
                def split = splits.get(num)
                echo "Class of split ${num} is ${split.class}"
          {{    }}}

           

          I expected the list elements to be of type InclusionExclusionPattern, but instead the output is this:

          [Pipeline] echo
          Class of splits is class java.util.ArrayList
          [Pipeline] echo
          Class of split 0 is class java.util.Collections$UnmodifiableRandomAccessList
          [Pipeline] echo
          Class of split 1 is class java.util.Collections$UnmodifiableRandomAccessList
          [Pipeline] echo
          Class of split 2 is class java.util.Collections$UnmodifiableRandomAccessList
          [Pipeline] echo
          Class of split 3 is class java.util.Collections$UnmodifiableRandomAccessList
          [Pipeline] echo
          Class of split 4 is class java.util.Collections$UnmodifiableRandomAccessList
          [Pipeline] echo
          Class of split 5 is class java.util.Collections$UnmodifiableRandomAccessList

          In fact, these are lists of Strings. I have no idea how this could happen.

          Christian Ciach added a comment - After updating Jenkins and some plugins to the current version today, I encounter this issue, too. I didn't change anything in my Jenkinsfile. Part of the stacktrace is: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field java.lang.String list     at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:397) Trying to debug this, i used this snipped inside my Jenkinsfile:       def splits = splitTests parallelism: count(6)     echo "Class of splits is ${splits.class}"     for (int i = 0; i < splits.size(); i++) {       def num = i       def split = splits.get(num)       echo "Class of split ${num} is ${split.class}" {{    }}}   I expected the list elements to be of type InclusionExclusionPattern, but instead the output is this: [Pipeline] echo Class of splits is class java.util.ArrayList [Pipeline] echo Class of split 0 is class java.util.Collections$UnmodifiableRandomAccessList [Pipeline] echo Class of split 1 is class java.util.Collections$UnmodifiableRandomAccessList [Pipeline] echo Class of split 2 is class java.util.Collections$UnmodifiableRandomAccessList [Pipeline] echo Class of split 3 is class java.util.Collections$UnmodifiableRandomAccessList [Pipeline] echo Class of split 4 is class java.util.Collections$UnmodifiableRandomAccessList [Pipeline] echo Class of split 5 is class java.util.Collections$UnmodifiableRandomAccessList In fact, these are lists of Strings. I have no idea how this could happen.

          Christian Ciach added a comment - - edited

          Actually, I don't fully understand why it worked for me ever before. I do not use inclusions (and never have, I checked our SCM), so, according to SplitStep.Execution.run() I should have gotten List<List<String>> as the return type, not List<InclusionExclusionPattern>.

          My best guess is that split.list.join("\n") worked for me before, because Jenkins allowed me to access the private field "list" inside "UnmodifiableList".

          Long story short: When not letting the plugin generate inclusions, the return type of splitTests is List<List<String>> instead of List<InclusionExclusionPattern>. If this is not documented, it should have been

          Christian Ciach added a comment - - edited Actually, I don't fully understand why it worked for me ever before. I do not use inclusions (and never have, I checked our SCM), so, according to  SplitStep.Execution.run() I should have gotten  List<List<String>> as the return type, not List<InclusionExclusionPattern> . My best guess is that  split.list.join("\n") worked for me before, because Jenkins allowed me to access the private field "list" inside "UnmodifiableList". Long story short: When not letting the plugin generate inclusions, the return type of  splitTests is  List<List<String>> instead of List<InclusionExclusionPattern> . If this is not documented, it should have been

          Hi christianciach

          I also encountered the same problem. Apparently, the return type has changed due to the following modifications. However, this seems to affect only if the generateInclusions option is false.

          https://github.com/jenkinsci/parallel-test-executor-plugin/commit/fce5c452cf2d683472049cfa313b821f2f7c131d#diff-edac883320f661584226d7e57aa70dd8

          https://github.com/jenkinsci/parallel-test-executor-plugin/pull/14#discussion-diff-36798939

          https://github.com/jenkinsci/parallel-test-executor-plugin/pull/14

           

          Incidentally, this behavior itself is explained in the document. However, there seems to be no announcement that compatibility is broken.
          https://jenkins.io/doc/pipeline/steps/parallel-test-executor/#splittests-split-test-runs

           

          If disabled, the splitStep call will return a List<List<String>> containing the exclusion patterns for the different buckets.
          If enabled, the splitStep call won't return a List<List<String>>.
          Instead it will return a List of a structure with :
          
          boolean includes whether the following list is an inclusion or an exclusion list List<String> list the list of patterns
           
          

           

          Daisuke Yoshimoto added a comment - Hi christianciach I also encountered the same problem. Apparently, the return type has changed due to the following modifications. However, this seems to affect only if the generateInclusions option is false. https://github.com/jenkinsci/parallel-test-executor-plugin/commit/fce5c452cf2d683472049cfa313b821f2f7c131d#diff-edac883320f661584226d7e57aa70dd8 https://github.com/jenkinsci/parallel-test-executor-plugin/pull/14#discussion-diff-36798939 https://github.com/jenkinsci/parallel-test-executor-plugin/pull/14   Incidentally, this behavior itself is explained in the document. However, there seems to be no announcement that compatibility is broken. https://jenkins.io/doc/pipeline/steps/parallel-test-executor/#splittests-split-test-runs   If disabled, the splitStep call will return a List<List< String >> containing the exclusion patterns for the different buckets. If enabled, the splitStep call won't return a List<List< String >>. Instead it will return a List of a structure with : boolean includes whether the following list is an inclusion or an exclusion list List< String > list the list of patterns    

            Unassigned Unassigned
            ghs1 g hs1
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: