jenkins - Jenkins Pipeline - Codeception 测试 publishHTML - 没有 HTML 显示
问题描述
我有一个 Jenkins 管道,它构建了一个 docker 实例来启动一个 Symfony 项目,效果很好。我们使用 codeception 进行测试,我想将其添加到管道中,并在 Jenkins 中显示每个构建的代码覆盖率。
管道成功运行,测试通过并生成 HTML,publishHTML 步骤似乎成功,但 Jenkins UI 中没有显示任何内容。(我什至不确定在哪里看,因为它只是在文档中说“在仪表板中”)。
管道的相关部分:
stage('Test') {
steps {
ansiColor('xterm') {
sh 'ssh jenkins@10.90.0.211 "sudo docker exec broccoli_app_1 ./vendor/bin/codecept run unit --env edge --coverage-html"'
}
}
}
}
post {
always {
echo 'Running post build script to publish report'
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'broccoli/tests/_output/coverage/', reportFiles: 'index.html', reportName: "HTML Report", reportTitles: "Coverage Report"])
}
}
在控制台中,它返回似乎是非失败消息:
[Pipeline] echo
Running post build script to publish report
[Pipeline] publishHTML
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /var/lib/jenkins/workspace/broccoli2stage/broccoli/tests/_output/coverage to /var/lib/jenkins/jobs/broccoli2stage/builds/56/htmlreports/HTML_20Report
[Pipeline] }
我还缺少其他配置吗?
解决方案
最终让这个工作。我认为我的解决方案不一定适用于许多情况。
你可以在这一行看到,我们登录到一个单独的服务器来运行测试:
sh 'ssh jenkins@10.90.0.211 "sudo docker exec broccoli_app_1 ./vendor/bin/codecept run unit --env edge --coverage-html"'
所以 publishHTML 无权访问代码运行结果。事实证明,我们不需要为这个构建设置这样做,所以只需在本地运行它就可以让它工作。
sh 'sudo docker exec broccoli_app_1 codecept run unit --env edge --coverage-html'
推荐阅读
- android - 为什么 Android 中的音乐服务不受打盹模式的影响?
- spring - 为什么我在 Spring 启动时遇到 TLSv1 问题以及如何解决?
- php - 在没有 php-library 的情况下连接到 php 邮件服务器
- python - 参数和 .upper() 中有多个单词
- javascript - 将评估结果保存到变量 - 噩梦般的网络抓取
- firefox-developer-tools - 在 Thuderbird 插件对话框中使用开发者工具
- python - 类实例不打印输入参数
- r - 有没有办法使用 R 计算点的导数
- javascript - JavaScript - 将数组放入视图模型,然后通过 AJAX 返回模型
- excel - 加入 2 个公式以检查 2 个单元格 (Excel 2007)