我有一个Jenkins管道,该管道构建了一个docker实例,并启动了一个Symfony项目,该项目运行良好。我们使用代码接收进行测试,我想将其添加到管道中,并在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] }
我还有其他配置吗?
答案 0 :(得分:0)
最终使它起作用。我认为我的解决方案不一定会适用于许多情况。
您可以在这一行中看到,我们正在登录到单独的服务器以运行测试:
getCall1() : Observable<any>{
if (condition)
return this.api.get('/call2');
else
return of(cachedData);
}
因此publishHTML无法访问代码运行结果。事实证明,我们不需要为此版本的设置进行此操作,因此只需在本地运行它即可工作。
sh 'ssh jenkins@10.90.0.211 "sudo docker exec broccoli_app_1 ./vendor/bin/codecept run unit --env edge --coverage-html"'