title: Jenkins CI Pipeline Scripts not permitted to use method groovy.lang.GroovyObject
body: <p>I am Using Jenkins 2 for compiling Java Projects, I want to read the version from a pom.xml, I was following this example:</p>
  
  <p><a href="https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md" rel="noreferrer">https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md</a></p>
  
  <p>The example suggest:</p>
  
  <p><a href="https://i.stack.imgur.com/OcCJM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OcCJM.png" alt="Full Jenkins Pipeline with problematic function circled"></a></p>
  
  <p>It seems that there is some security problem accessing the File System but I can't figure out what it is giving (or why) that problem:</p>
  
  <p>I am just doing a little bit different than the example:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>def version() {
      String path = pwd();
      def matcher = readFile("${path}/pom.xml") =~ '&lt;version&gt;(.+)&lt;/version&gt;'
      return matcher ? matcher[0][1] : null
  }
  </code></pre>
  
  <p>The Error I am getting when running the 'version' method :</p>
  
  <pre><code>org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (org.codehaus.groovy.runtime.GStringImpl call org.codehaus.groovy.runtime.GStringImpl)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:165)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:117)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:103)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
      at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)
      at WorkflowScript.run(WorkflowScript:71)
      at ___cps.transform___(Native Method)
      at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:55)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
      at sun.reflect.GeneratedMethodAccessor408.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:100)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
      at sun.reflect.GeneratedMethodAccessor408.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
      at sun.reflect.GeneratedMethodAccessor408.invoke(Unknown Source)
  </code></pre>
  
  <p>I am using these versions:
  Plugin Pipeline 2.1
  Jenkins 2.2</p>