title: How do I use Java classes (like java.net.URL) in a Jenkins Jenkinsfile sandbox?
body: <p>I'm building a Jenkinsfile which will need to use some Java standard library methods:</p>
  
  <p>For example, in one bit of the build script I need to extract a hostname from a URL provided as user input. I'd like to do something like this:</p>
  
  <pre><code>URI u = new URI(artifactoryIndexURL)
  </code></pre>
  
  <p>In another bit of the script I'd like to use java.lang.String to replace some string content with some other string content.</p>
  
  <p>Unfortunately the classes appears not to be white-listed (or something like that):</p>
  
  <pre><code>org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new java.net.URI java.lang.String
      at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectNew(StaticWhitelist.java:187)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:130)
      at org.kohsuke.groovy.sandbox.impl.Checker$3.call(Checker.java:191)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedConstructor(Checker.java:188)
      at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.constructorCall(SandboxInvoker.java:20)
  </code></pre>
  
  <p>It looks like the Jenkins default Sandbox excludes all but a very tiny core of methods. Is there a way to allow me to run certain Java classes in my Jenkinsfile that doesn't require me to get full admin rights on my Jenkins server? What is the normal way of getting around this problem?</p>