1

我正在尝试将 HTML 页面内容显示到 Jenkins 电子邮件的正文中,我将以下代码添加到可编辑电子邮件插件的默认内容部分:

${FILE,path="/target/surefire-reports/html/index.html"}

我还尝试将以下代码添加到电子邮件插件中的预发送脚本:

def reportPath = build.getWorkspace().child("HealthTestResults.html")
msg.setContent(reportPath.readToString(), "text/html");

这两种方式都不起作用,我仍然收到空邮件。

4

2 回答 2

0

试过了${FILE,path="target/surefire-reports/html/index.html"}吗?即没有 /

于 2017-06-21T08:43:32.547 回答
0

如果你不想再找一份 Jenkins 工作,试试 DSL 怎么样

你可以:

  1. 添加一个新的构建步骤“Process Job DSLs”(您将需要Job DSL Plugin
  2. 将此 Groovy 脚本添加到“使用提供的 DSL 脚本”字段

Groovy 脚本

job(jobname_to_your_email_job) {
  publishers {
    extendedEmail {
      recipientList(your_email_list)
      defaultSubject(your_subject)
      defaultContent(your_default_content)
      contentType('text/html')
      triggers {
        always {
          subject(your_subject)
          //read your html file and put it in the content field
          content(readFileFromWorkspace(path_to_your_html_file))
          sendTo {
            recipientList()
          }
        }
      }
    }
  }
}
//This will put your email job to the build queue so your email job will run automatically
queue("Email Report")

当然,您可以根据文档自定义这部分

于 2017-04-06T23:21:56.920 回答