1、安装插件
Manage Jenkins → Manage Plugins
→ 安装robot插件 Robot Framework plugin
→ 安装Groovy插件 Groovy

2、新建Item
任务名称:test(自定义,必填)
选择自由风格的项目:Freestyle project
点<确定>

3、配置
① 构建触发器:
勾选Build periodically
日程表:* * * * * 表示任务在什么时候触发执行,不写的可以用*表示

② 构建:
Execute Windows batch command 执行windows批处理命令
命令: robot -d 报告生成报告地址 项目路径
或者: pybot -d 报告生成报告地址 项目路径

再次增加构建步骤:
Execute system Groovy script
Groovy Script : System.setProperty(“hudson.model.DirectoryBrowserSupport.CSP”,””)

③ 构建后操作:
Publish RobotFramework test results
Directory of Robot output:报告地址

点高级

最后点确定即可
4、可能出现的问题
点击日志出现:

官方说明:
1 | Jenkins 1.641 / Jenkins 1.625.3 introduce the Content-Security-Policy header to static files served by Jenkins (specifically, DirectoryBrowserSupport). This header is set to a very restrictive default set of permissions to protect Jenkins users from malicious HTML/JS files in workspaces, /userContent, or archived artifacts. |
解决方法:
找到jenkins的安装目录下的jenkins.xml,修改此文件
修改前:
1 | <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080</arguments> |
修改后:
1 | <arguments>-Xrs -Xmx256m -Dhudson.model.DirectoryBrowserSupport.CSP= -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments> |
一定要重启jenkins,最好能再执行一下测试脚本,让它生成新的报告文件就行了。