html - 将 HTML 输出嵌入 Jenkins 仪表板
问题描述
我是詹金斯的新手,我正在努力解决一个问题。我想将 HTML 输出嵌入到 jenkins 仪表板中。我尝试了几种方法,但都没有成功。这是我获取 html 输出的管道阶段的代码片段:
stage('Test score Calculations'){
steps{
script{
ansiColor('xterm') {
def buildSummaryFragments = ["""<table border="1px"><thead><tr>
<th>Module</th>
<th>Lint</th>
<th>Unit Test</th>
<th>Behave Test</th>
<th>Coverage</th>
</tr></thead><tbody>"""]
def ms_file = readFile "mod_ms.txt"
def files = ms_file.split("\n")
for (int msCount = 0; msCount< files.size();msCount++) {
println "preparing summary for ${files[msCount]}"
buildSummaryFragments += [createBuildSummary("${files[msCount]}")]
}
buildSummaryFragments += ["</tbody></table>"]
println(buildSummaryFragments)
简而言之,这里发生了什么:
- 该脚本正在从文本文件中读取应用程序名称
- 对于每个名称,它在 createBuildSummary() 函数中对这些应用程序进行一些测试,其输出以 html 格式出现并存储在 buildSummaryFragments
buildSummaryFragments 的输出如下所示:
16:34:57 [<table border="1px"><thead><tr>
16:34:57 <th>Module</th>
16:34:57 <th>Lint</th>
16:34:57 <th>Unit Test</th>
16:34:57 <th>Behave Test</th>
16:34:57 <th>Coverage</th>
16:34:57 </tr></thead><tbody>, <tr>
16:34:57 <td style="background-color:#d9eedb;">cloudx_demo_service</td>
16:34:57 <td style="background-color:#d9eedb;">9.23/10 (previous run: 9.23/10, +0.00)</td>
16:34:57 <td style="background-color:#d9eedb;">nosetests: 1/1 passed: 100% success
16:34:57 </td>
16:34:57 <td style="background-color:#d9eedb;"><Element 'testsuite' at 0x7ff60219f410>
16:34:57 service.Heart beat for the demo App: 1/1 passed: 100% success
16:34:57 </td>
16:34:57 <td style="background-color:#d9eedb;">100%
16:34:57 </td>
16:34:57 </tr>, </tbody></table>]
我想将此 html 结果附加到构建的仪表板中。在仪表板中,它会给我一个像这样的表格:
我想将此 buildSummaryFragments 存储在 html 文件中。您能否建议如何将其写入文件 - 使用以下两种方式:
- 尝试使用 groovy 写入 html(我在执行此操作时遇到了两个问题 - 一个具有写入权限,第二个是变量类型为 arraylist 而不是字符串)
- 我尝试在 shell 中做一个回声。但由于大量特殊字符无法正常工作。请建议使用什么过滤器。
这个你能帮我吗。提前致谢
解决方案
推荐阅读
- jquery - jQuery substr 不影响所选元素
- python - 在 Python 中是否使用 http.client 或 Socket 包?
- c# - 将所选项目从 listbox1 移动到 listbox2,保存到 db 的问题
- java - 如何识别与模式不匹配的数据
- angular - 如何在 ionic & angular 2 中检索对象?
- sql - 来自 2 个表的 SQL 计数为真/假
- git - 从 GitHub 拉 PR 时出现上游错误
- java - 如何修复记录器在同一行上随机记录,即使它设置为以新行开始每个日志
- r - 我如何计算长度为 n = 20 的变量 v 与 m 其他变量之间的相关性(其中 m 的范围从 1 到 100)
- vue.js - 如何对使用 nuxt-i18n 的 Vue.js 组件进行单元测试