2017-04-05 76 views
0

我试图显示HTML网页内容到詹金斯电子邮件的正文中,我下面的代码添加到编辑邮箱插件的默认内容部分:显示HTML网页内容划分詹金斯电子邮件

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

也我试图添加以下代码的电子邮件插件预发送脚本:

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

两者的双向没有工作,我仍然收到空邮件。

回答

0

什么有DSL一试,如果你不烦多了一个詹金斯工作

您可以:

  1. 添加一个新的构建步骤“处理工作的DSL”(您需要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") 

和当然,你可以根据Docs

+0

它没有工作,我仍然收到空邮件 – Roni

+0

你可以去检查这个groovy脚本创建的工作,以查看后编译步骤中的“可编辑电子邮件”的内容字段?它是否为空? – Chong

+0

我使用了上面提到的Groovy脚本。我检查了由groovy脚本创建的作业。内容字段包含html脚本...但仅收到空邮件 – user2439278

0

试过${FILE,path="target/surefire-reports/html/index.html"}定制这部分?即没有/