Cannot evaluate ArrayList.size or first inside Groovy Sandbox

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Might be related to JENKINS-50470, some people commented there that they have this problem.

      1. Create a freestyle job
      2. Add "Execute system Groovy script" build step
      3. Add content (see below)
      4. Run build with "Use Groovy Sandbox" enabled.
      5. Run without "Use Groovy Sandbox" enabled

      Script content:

      def someList = [1, 2, 3]
      println someList.size

      When the sandbox is enabled we have the following message :
      ERROR: Build step failed with exceptionorg.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field hudson.slaves.EnvironmentVariablesNodeProperty size
      It is not a field but a method, called without parentheses. It breaks many of our scripts, using methods such as first or size.

       

      Thanks for your help !

       

            Assignee:
            Unassigned
            Reporter:
            Michael Piffret
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: