使用 EMail-ext 插件,我们如何使用 def fileContent = readFile "filePath" 发送存储在变量中的文件内容
pipeline {
agent {
label 'test'
}
tools {
jdk 'JDK_HOME'
maven 'MAVEN_HOME'
}
stages {
stage('clean') {
steps {
script {
sh 'mvn clean'
}
}
}
stage('check server status') {
steps {
script{
sh 'mvn verify'
}
}
}
}
post{
success{
def fileDetails = readFile "./EnvironmentLinks.txt"
def linesInFile = fileDetails.readLines()
emailext to: "${env.DEFAULT_MAIL_LIST}",
mimeType: 'text/html',
from: "[email protected]",
attachmentsPattern: '**/html-report/*.html',
subject: "Test Email",
body: """
<p style=font-family:calibri;font-size:15px>Hi - This is a test email </p>
<p style=font-family:calibri;font-size:13.7px;><b>File Details:</b><br>
${linesInFile}</p>
}
}
linesInFile 返回一个列表。在电子邮件中,它显示如下:
嗨 - 这是一封测试邮件 文件详情: [测试一、测试二、测试三]
But what I am expecting is :
Hi - This is a test email
File Details:
Test1
Test2
Test3
在这方面有什么帮助/建议吗?