在 HTML 页面中使用 Jenkins 中的 Email-ext 插件打印用户定义的变量



我在 jenkins 管道脚本中使用电子邮件分机,并带有对文件的电子邮件正文引用。我想知道如何传递用户定义的变量。 例如:- 我想将变量"mySonarURL"和"myData"传递给HTML文件。

def committer = getGitCommitterEmail()
def mySonarURL = "My Sonar URL"
def myData = "My Data"
emailext (
to: committer,
subject: "Jenkins Build ${branchName} #${env.BUILD_NUMBER} [${currentBuild.result}]",
body: '${FILE,path="email.html"}',
mimeType: 'text/html'
)
}

网页文件

<table>
<tr><th>My Data:</th><td>"${myData}"</td></tr>
<tr><th>Sonar URL:</th><td><a href="${mySonarURL}">Sonar URL</a></td></tr>
</table>

我尝试使用上面的HTML文件,但他们只返回字符串"${myData}"和"${mySonarURL}">

按照官方 Jenkins wiki 中的指导,在邮件正文中提及类型作为脚本

body: '${SCRIPT, template="email.html"}'

最新更新