Jenkins combined with ANT send a test report

Global variable volume configuration

Click ManageJenkins into the management Jenkins

 

 

  Click Global Tool Configuration Enter global configuration variables

 

 

  Configuring Ant, Name a better understanding of their own definition of the name.

  Install automatically remove the check, fill Ant path input box will appear.

  After the name of the definition of fill in the path of server storage Ant.

  If you installed the Ant useless check Install automatically, Jenkins will automatically install Ant.

 

 

  Configure Java JDK.

  Ant and the same configuration.

   

  Be applied after Ant and Java JDK configuration is complete and saved.

 

New Task

  Enter the name of the task

  Select the Freestyle project, the project own style, then the next step.

  

 

  Select Invoke Ant Build in Construction

   

 

  Open Advanced Advanced Settings, fill in the file path in the Build File build.xml build file.

  

  Then apply and save.

 

  Click Build Now be run in the project, you can view the results.

  After the run is completed you can see the history of # 1 to build a build of.

   

 

  Click the down arrow in the build history, select the Console Output to view the build results in the console.

   

 

Plug-in installation

  From the main Jenkins, select Manage Jenkins, then select Manage Plugins into the plug-in management.

   

 

  Filter in the upper right corner of the search Available HTML report HTML Publisher plug-in installation.

  Search Mail email-ext-recipients-column Filter plug-in at the upper right corner Available in installation.

  Since the automatic installation is relatively slow, so I choose Jenkins widget management https://www.cnblogs.com/tynam/p/11470244.html download email-ext-recipients-column widget and then introduced into the insert Jenkins.

   

   After downloading the plug-in to upload Advanced Advanced settings Jenkins plug-managed.

  

 

HTML report configuration

  After installation is complete, enter the project management, the project carried out HTML report configuration.

   

 

  Add Publish HTML reports HTML report released under operation after Post-build Actions building.

   

 

Reports on the set, HTML directory complete the report in the storage path to archive.

Add matching Index page [s] in html file, the file name to * means match all html files.

 

 

  After configuration and application were saved.

  Return projects, re-execute the build now, after the completion of the implementation will be more of a HTML Report item.

   

 

  Enter HTML Report.

   

 

  Click TestReport201911081155.html view the generated reports.

 

The report generated a lack of style, so it looks ugly.

The reason for this phenomenon is that Jenkinsin the configuration CSP( Content Security Policy). This is Jenkinsa security policy, the default is set to a very strict set of permissions to prevent users Jenkins workspace, /userContent, archived artifactsthe malicious HTML/JSfile attacks.

The solution to this problem in detail, please read the article: https://testerhome.com/topics/9476

   After resolving view HTML Report again

 

Mail configuration

获取邮箱的授权码

具体操作请查看博文 https://www.cnblogs.com/tynam/p/8759119.html  中163邮箱设置,获取授权码。

 

Jenkins 系统配置

从Jenkins 主要中,选择 Manage Jenkins ,然后选择 Configure System 进入系统配置。

   

 

  添加管理员邮箱地址

 

 

  填写SMTP server ,用户邮箱地址、授权码(这儿的密码填写的是授权密码并非登录密码)、端口号。

 

 

   编辑发送邮件内容

选择默认发送邮件样式 HTML(text/html)。

填写邮件主题:QA构建通知:$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!

选择发送邮件模板:${SCRIPT,template="groovy-html.template"}

因为默认提供的邮件内容过于简单,所以使用Email Extension Plugin 提供的Groovy标准HTML模板:groovy-html.template

 

  配置完成后进行应用并且保存。

 

  再次进行项目配置,对邮件发送进行设置。

  在 Post-build Actions 构建后操作下添加 Editable Email Notification 电子邮件通知。

  在 Project Recipient List 中添加收件人,多人情况下之间需要用分号隔开。

 

 

  在advanced中设置邮件发送触发

  删除默认的设置

 

 

  将触发邮件发送改变为 Always 总是。当然触发修改根据自己具体实际情况进行修改。

 

 

  其他设置保持默认即可。

  应用保存。

  进行立即构建 build now。

  进入邮箱查看接收的邮件。

 

 

Guess you like

Origin www.cnblogs.com/tynam/p/11821563.html