Sandbox is preventing me from formatting a string

一世执手 提交于 2019-12-30 09:56:13

问题


I have a simple groovy script:

node ("master")
{
  echo "I am about to try to use String.format"
  def jjj = String.format("bob")
  echo jjj 
}

If I put this script right into my job configuration and run it, it runs fine.

But if I put that script into a file which I then load via "Workflow script from SCM", I get the error

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified staticMethod java.lang.String format java.lang.String

How do I work around this? Is it possible to turn off the sandbox for "Workflow script from SCM" like it is for "Workflow script"?

Or is there some sandbox-approved way of formatting a string in groovy?

And why is it preventing me from formatting a string in the first place?


回答1:


I think it's not possible to disable sandboxing when using Workflow script from SCM

However you can approve the usage here:

http://<jenkins_host>:<port>/scriptApproval/



回答2:


How do I work around this?

Possibly (untested)

String.format("bob", [])

rather than using varargs. At any rate you should file a bug in JIRA (component script-security-plugin, label workflow) with steps to reproduce.

Is it possible to turn off the sandbox for "Workflow script from SCM" like it is for "Workflow script"?

No: JENKINS-28178



来源:https://stackoverflow.com/questions/33573568/sandbox-is-preventing-me-from-formatting-a-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!