我有一个管道来扫描编译器警告,最近注意到由于脚本安全审批,发布命令无法执行管理 Jenkins 中定义的 groovy 脚本。 投诉针对:
Groovy sandbox rejected the parsing script for parser GHS MULTI No-Wrap: Scripts not permitted to use method java.util.regex.MatchResult group int. You will need to manually approve the call in the Script Approval UI.
所以我批准了它,但每次构建都会回来。这只会影响我的自定义解析器。
我是否错误地使用了自定义解析器,或者这会成为脚本安全问题吗?
解析器正则表达式:
^"+(.*)".*line\s(\d*):.*(error|warning)\s*#(.*):\s*(.*)$
解析器脚本:
import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority
String fileName = matcher.group(1)
String lineNumber = matcher.group(2)
String category = matcher.group(3)
String typeID = matcher.group(4)
String message = matcher.group(5)
if(category == "warning"){
return new Warning(fileName, Integer.parseInt(lineNumber), typeID,
category, message, Priority.NORMAL);
}
else if(category == "error"){
return new Warning(fileName, Integer.parseInt(lineNumber), typeID,
category, message, Priority.HIGH);
}
更新:我发现我收到的错误我相信是由警告解析器 here 生成的
我找不到任何关于为什么或我能做些什么来防止它抛出异常的信息。
最佳答案
我发现该问题与 4.62 版警告插件的发布有关。这是一个修复一些安全问题的版本。目前,恢复到 4.60 可以解决该问题。
关于Jenkins Pipeline 扫描编译器警告自定义解析器被阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43596758/