沙盒阻止我格式化字符串 [英] Sandbox is preventing me from formatting a string

查看:18
本文介绍了沙盒阻止我格式化字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 groovy 脚本:

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.

但是,如果我将该脚本放入一个文件中,然后通过来自 SCM 的工作流脚本"加载该文件,我会收到错误

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

我该如何解决这个问题?是否可以像工作流脚本"一样关闭来自 SCM 的工作流脚本"的沙箱?

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"?

或者是否有一些沙盒认可的方式在 groovy 中格式化字符串?

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?

推荐答案

我认为使用 SCM 中的工作流脚本时无法禁用沙盒

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/

这篇关于沙盒阻止我格式化字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆