在Ubuntu上使用Jenkins生成报告可以通过以下几种方法实现:
安装HTML Publisher插件:
配置Job以生成HTML测试报告:
mvn clean test
gradle clean test
pytest --html=report/result.html --self-contained-html
report
文件夹下,则填写report
。result.html
,则填写result.html
。解决HTML报告样式加载问题:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
import jenkins.model.Jenkins
Jenkins.instance.getAllItems(AbstractItem.class).each { item ->
if (item instanceof hudson.model.Job) {
item.getBuilds().each { build ->
build.getResults().each { result ->
if (result instanceof hudson.tasks.junit.JUnitResultArchiver) {
result.getReportDir().each { dir ->
def reportDir = dir.path
def reportFiles = dir.listFiles { file ->
file.name.endsWith('.html')
}.collect { file ->
[
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: reportDir,
reportFiles: file.name,
reportName: 'HTML Report'
]
}.each { config ->
build.post.publishHTML(config)
}
}
}
}
}
}
}
执行构建并查看报告:
通过以上步骤,你可以在Ubuntu上使用Jenkins生成和查看HTML测试报告。根据你的具体需求,可以进一步调整和扩展配置。