我有一个 JenkinsFile,我在其中使用 emailext 发送邮件以获取自动化结果
def subject = "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}"
def color = currentBuild.currentResult == 'FAILURE' ? 'red' : 'green'
emailext (
mimeType: 'text/html',
attachLog: true,
subject: subject,
body:
"""
<h3><font color='${color}'>${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} </h3></font><br> More info at: ${env.BUILD_URL}<br><br>
Total test case: \${TEST_COUNTS,var="total"} <br>
Pass: \${TEST_COUNTS,var="pass"} <br>
Fail: \${TEST_COUNTS,var="fail"} <br>
<br>
${htmlTable}
<br>
\${BUILD_LOG_REGEX, regex="^.*Check out job at", showTruncatedLines="false",substText=" Access the test recording here:"}<br><br>
<p>Click the link below to view the report:</p><a href="${env.BUILD_URL}/QmateReport">View Report</a>
""",
to: '[email protected]'
)
对于此行 - ${BUILD_LOG_REGEX, regex="^.*Check out job at", showTruncatedLines="false",substText=" 在此处访问测试记录:"}
我收到了多个匹配项,并且全部以未格式化的方式排列在一行中。
有没有办法在 NextLine 中获取电子邮件中那些匹配的记录
我想在 NextLine 中看到这个
在此处访问录音:
在这里访问录音:
我尝试使用以下两点
\${BUILD_LOG_REGEX, regex="^.*Check out job at", showTruncatedLines="false",substText=" Access the test recording here: \n"}<br><be>
\${BUILD_LOG_REGEX, regex="^.*Check out job at", showTruncatedLines="false",substText=" Access the test recording here:
"}
但是没有任何效果,请帮忙。
自
2.0-beta版本开始,
BUILD_LOG_REGEX
宏始终支持默认为 true 的 addNewline
属性。它应该已经在每场比赛的末尾放置一个新行字符。
但是,如果这不起作用,可以尝试使用
matchedLineHtmlStyle
属性,该属性允许您为每个表达式匹配提供样式。例如,以下 matchedLineHtmlStyle
值会在匹配之间产生干净的新行分隔:
emailext (
mimeType: 'text/html',
attachLog: true,
subject: subject,
body:
"""
<h3><font color='${color}'>${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} </h3></font><br> More info at: ${env.BUILD_URL}<br><br>
Total test case: \${TEST_COUNTS,var="total"} <br>
Pass: \${TEST_COUNTS,var="pass"} <br>
Fail: \${TEST_COUNTS,var="fail"} <br>
<br>
${htmlTable}
<br>
\${BUILD_LOG_REGEX, regex="^.*Check out job at", showTruncatedLines="false", matchedLineHtmlStyle="margin-bottom: 1em; display: inline-block;", addNewline="true", substText=" Access the test recording here:"}<br><br>
<p>Click the link below to view the report:</p><a href="${env.BUILD_URL}/QmateReport">View Report</a>
""",
to: '[email protected]'
)