Hello group,

I was trying to use a groovy construct where I could give a closure with an 
argument, and pass that closure to a function, something like this below:

class Test {
  int num = 5
}

def runit(def func) {
  echo "Will run it"
  def obj = new Test()
  func(obj)
  echo "Ran it"
}

node {
  runit({ obj ->
    echo "I am running:" + obj.num
  })
}

But I get an access error from the script sandbox. So I checked but there 
were no pending approvals in the jenkins management configuration. 
So I don't know how to handle such a situation?

I got this error:

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts 
not permitted to use method groovy.lang.Closure call java.lang.Object
        at 
org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:150)
        at 
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:77)
        at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:103)
        at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:100)
        at 
com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)

                ......

Is there some other construct I can use to achieve the same?
Thanks,
Best regards,
Tom,

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/81790551-42dc-404b-bd87-5825b5e7202e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to