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

RejectedAccessException thrown but no pending script approval added

    • workflow-cps 2.67

      When using

      new GetMethod(url)

      from

      import org.apache.commons.httpclient.HttpClient
      import org.apache.commons.httpclient.methods.GetMethod

      directly in a Workflow script pasted into the UI, everything works as expected.

      When the script is loaded with the file loader plugin during the Workflow script, the following error occurs:

      org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new org.apache.commons.httpclient.methods.GetMethod java.lang.String

      No pending script approval is generated.

          [JENKINS-34973] RejectedAccessException thrown but no pending script approval added

          Tobias Larscheid created issue -
          Tobias Larscheid made changes -
          Description Original: When using

          {{new GetMethod(url)}}

          from

          {{import org.apache.commons.httpclient.HttpClient
          import org.apache.commons.httpclient.methods.GetMethod}}

          directly in a Workflow script pasted into the UI, everything works as expected.

          When the script is loaded with the file loader plugin during the Workflow script, the following error occurs:

          {{org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new org.apache.commons.httpclient.methods.GetMethod java.lang.String}}

          No pending script approval is generated.
          New: When using

          {{new GetMethod(url)}}

          from

          {{import org.apache.commons.httpclient.HttpClient}}
          {{import org.apache.commons.httpclient.methods.GetMethod}}

          directly in a Workflow script pasted into the UI, everything works as expected.

          When the script is loaded with the file loader plugin during the Workflow script, the following error occurs:

          {{org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new org.apache.commons.httpclient.methods.GetMethod java.lang.String}}

          No pending script approval is generated.
          Jesse Glick made changes -
          Summary Original: Workflow scripts not permitted to use apache http client get method New: RejectedAccessException thrown but no pending script approval added

          Jesse Glick added a comment -

          Adjusted summary to reflect the actual bug.

          Anyway you should avoid using libraries like this from Pipeline script. See this plugin, or simply call tools like curl from a sh or bat step.

          Jesse Glick added a comment - Adjusted summary to reflect the actual bug. Anyway you should avoid using libraries like this from Pipeline script. See this plugin , or simply call tools like curl from a sh or bat step.
          Jesse Glick made changes -
          Epic Link New: JENKINS-35391 [ 171184 ]

          Marcus Philip added a comment -

          I have same problem using groovy.json.JsonSlurper().parse(url).
          How am I supposed to do that?

          Marcus Philip added a comment - I have same problem using groovy.json.JsonSlurper().parse(url). How am I supposed to do that?
          Marcus Philip made changes -
          Comment [ I have same problem using groovy.json.JsonSlurper().parse(url).
          How am I supposed to do that? ]

          Marcus Philip added a comment -

          It seems the workaround is to do groovy.json.JsonSlurper().parseText(url.getText()).

          This might be due to the groovy version used under the hood in pipeline plugin, but I fail to find out what this is.

          Marcus Philip added a comment - It seems the workaround is to do groovy.json.JsonSlurper().parseText(url.getText()). This might be due to the groovy version used under the hood in pipeline plugin, but I fail to find out what this is.

          Sebastian Pieck added a comment - - edited

          Hi,

          I'm having the same problem opening a URL-connection. This code:

          def soapUrl = new URL("http://testURL")
          def connection = soapUrl.openConnection()
          

          triggers this message: Scripts not permitted to use method java.net.URL openConnection
          So far so good, but I can't approve it, I have no option to do so.
          Using the http-request-plugin instead of native calls is a good alternative for me.
          Thanks for the suggestion

          Sebastian Pieck added a comment - - edited Hi, I'm having the same problem opening a URL-connection. This code: def soapUrl = new URL( "http: //testURL" ) def connection = soapUrl.openConnection() triggers this message: Scripts not permitted to use method java.net.URL openConnection So far so good, but I can't approve it, I have no option to do so. Using the http-request-plugin instead of native calls is a good alternative for me. Thanks for the suggestion
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 171177 ] New: JNJira + In-Review [ 184209 ]

            jglick Jesse Glick
            tobilarscheid Tobias Larscheid
            Votes:
            10 Vote for this issue
            Watchers:
            28 Start watching this issue

              Created:
              Updated:
              Resolved: