How to Send Performance Trend Graph as image via email with jenkins

1.3k views Asked by At

I am integrating Jmeter test cases with Jenkins and using performance plugin able to see trend graph.

Is there any way to to send these graphs in jenkin's triggered email? I am using Performance plugin of 3.11 version and email -ext plugin to send email. While investing how to do it I found link

but it is not working in my case. In my jenkins project build path /test/trend path is not available. Are we actually storing trend graph as image anywhere or it is runtime implementation ?

Please help to know how to send these performance trend graph as email

1

There are 1 answers

0
sunny_teo On

I am not able to find any direct approach. So, I have tried the below:-

  1. Create one project with the below:-

    a. Build - execute the jmx for performance

    b. Post build action:- This one is to Publish performance test result report. In the same post build step, I have add one more i.e. Build other project and give name of the 2nd project(Send Reports) which is taking the snapshot and triggering the mail

  2. Create 2nd project (Send Reports) with the below:-

    a. Build - execute the snapshot script.

    b. Post build action:-Send email with the snapshot generated in step a. Snapshot below for capturing the performance trend:- enter image description here

Code:-

// Importing packages (and all classes in package) from Java into Javascript
var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var fileUtils = JavaImporter(org.apache.commons.io.FileUtils)
var timeunit = java.util.concurrent.TimeUnit

//Login
WDS.browser.get("http://localhost:8080/")
var username = WDS.browser.findElement(pkg.By.id('j_username')).sendKeys(['Your_Username']);
var password = WDS.browser.findElement(pkg.By.name('j_password')).sendKeys(['Your_passowrd']);
var LogInBtn = WDS.browser.findElement(pkg.By.name('Submit')).click();

//Navigation
var ProjectLink = WDS.browser.findElement(pkg.By.linkText('Test_FreestyleProject')).click(); 
var PerformanceTrend = WDS.browser.findElement(pkg.By.linkText('Performance Trend')).click(); 

//Screenshot
var screenshot = WDS.browser.getScreenshotAs(pkg.OutputType.FILE)
screenshot.renameTo(new java.io.File("D:/pathtosnapshot/workspace/SendReport/" + "Performance_Report.png" ))

Once it is setup, first project will trigger the second project on completion and second project will take the snapshot and send the email. Now, you need to check your navigation in your project and modify the script according to your requirements like for timestamp, build identification etc.

I have check all the above except for the mail triggering part. I am getting success for the email and no error in the output log, but the mail is not triggering. It may be SMTP configuration or something else.

Hope this helps.