1

I want to use FTP in Groovy(Jenkinsfile).But got this error log.I thinks cased by Groovy sandbox,Can I shutdown it?

Here is my config at the top of file.

@Grapes([
        @Grab(group='commons-net', module='commons-net', version='3.3'),
        @GrabConfig(systemClassLoader=true)
    ])

Here is my log:

java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:432)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:67)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:411)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:374)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:220)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:401)
Caused by: java.lang.RuntimeException: No suitable ClassLoader found for grab
Cœur
  • 37,241
  • 25
  • 195
  • 267
Carlos
  • 23
  • 4
  • It does not seem because of Jenkins Groovy sandbox as far as I see the stack trace. How come did you think because of it? It might be related to this: http://stackoverflow.com/questions/4611230/no-suitable-classloader-found-for-grab – arasio Nov 09 '16 at 13:50
  • Yeah,I have seen this.But How can I import org.apache.commons.net.ftp.*? – Carlos Nov 09 '16 at 14:00
  • After I deleted @Grab.Log like this: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new org.apache.commons.net.ftp.FTPSClient boolean – Carlos Nov 09 '16 at 14:10

0 Answers0