In a jenkinsfile using a shared library (configured on a jenkins folder/untrusted) I have the following line:
def itemTime = Instant.parse("2018-02-27T13:33:36Z")
When I run my pipeline I get:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod java.time.Instant parse java.lang.CharSequence
at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectStaticMethod(StaticWhitelist.java:189)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onStaticCall(SandboxInterceptor.java:150)
at org.kohsuke.groovy.sandbox.impl.Checker$2.call(Checker.java:184)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedStaticCall(Checker.java:188)
Of course I can manually approve the script method:
staticMethod java.time.Instant parse java.lang.CharSequence
on the Jenkins master and I also looked at:
Jenkins CI Pipeline Scripts not permitted to use method groovy.lang.GroovyObject
But:
- Why is that method blacklisted in the first place?
- How do I parse the above date using only white listed methods?