我正在使用脚本执行某些操作并将结果写入文件。最后,我应该将文件的内容发送给 Jenkins Job 的指定用户。
使用以下代码获取输出。
def result=readFile("output")
echo "${result}"
desired = result.split("\n")
notify("${desired}")
但这对我的期望没有帮助。问题是内容显示为如下元素列表:
persistentvolumeclaims is above threshold value with usage of 7 , secrets is above threshold value with usage of 12 , replicationcontrollers is above threshold value with usage of 29
但是文件的实际内容是正确的格式:
**********************************************************************
opprovdemo
**********************************************************************
persistentvolumeclaims is above threshold value with usage of 7
secrets is above threshold value with usage of 12
replicationcontrollers is above threshold value with usage of 29
甚至尝试过这段代码:
def result=readFile("output")
echo "${result}"
notify("${desired}")
但没有用,它只是显示为这样的段落:
********************************************************************** opprovdemo ********************************************************************** persistentvolumeclaims is above threshold value with usage of 7 secrets is above threshold value with usage of 12 replicationcontrollers is above threshold value with usage of 29
添加通知功能详细信息:
def notify(status){
emailext (
to: "email-id",
subject: "'${env.BUILD_TAG}!'",
attachLog: true,
body: """<style>
body, table, td, th, p {
font-family:verdana,helvetica,sans serif;
font-size:11px;
color:black;
}
td.bg1 { color:white; background-color:#595959; font-size:120% }
td.console { font-family:courier new, lucida console; }
</style>
<body>
<table border=2 cellspacing=2 cellpadding=2 width="40%">
<tr>
<td align="left" width="30%">
<img
src="*****/headshot.png" />
</td>
<td valign="center" width="70%">
<b style="font-size: 170%;">OSE RESOURCE USAGE INFORMATION</b>
</td>
</tr>
<tr>
<td>URL:</td>
<td>
<a href='${env.BUILD_URL}'>${env.JOB_NAME}</a>
</td>
</tr>
<tr>
<td>BUILD STATUS:</td>
<td>${status}</td>
</tr>
<tr>
<td>DATE/TIME:</td>
<td>${env.BUILD_TIMESTAMP}</td>
</tr>
</table>
<br />
</body>"""
)
}
应该怎么做才能使内容以与输出文件相同的方式显示?