jenkins里html报告无法执行js,解决方法

问题

  • jenkins生成的报告,无法运行js,console报错jenkins Blocked script execution in '<URL>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.

解决方法

  • 启动jenkins的环境变量里加上这个配置
- name: JAVA_OPTS
  value: >-
    -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-scripts; script-src 'self' 'unsafe-inline' 'unsafe-eval';"