This is a simple project to show how to integrate robot run in jenkins with freestyle project. Robotframework-jenkins-run also provide step by step to poll scm push to trigger the build. It also helps on using robotframework-metrics to view the dashboard report on jenkins.
Troubleshooting viewing report
- Clone this project on your local computer.
https://github.com/Anilkumar-Shrestha/robotframework-jenkins-run.git
- install Jenkins on your PC. for installation, follow steps as: install jenkins on windows note: Sometime you will find Jenkins under C:\windows\system32\config\systemprofile\AppData\Local\jenkins.jenkins folder after jenkis installation.
- Go to "Manage Jenkins" in left bar and click on "plugin Manager". You will see the horizontal bar, click on Available and type "Robot Framework plugin" on search bar. Install the plugin without restart.
- Create New item.
- Give a suitable project name and select the free style project and click on OK button as shown.
- Go to Source code management and select Git radiobutton. Provide the repos url and give your credentials.
for Credential setting, please see the link Adding credentials
- Go to Build trigger and select the Poll SCM button and enter 5 * with spaces to check changes in every minutes.
- Go to Build and click on Add build steps. It pop up the list where you should click on "Execute Window batch Command".
- Enter the below batch cmd on the command box as shown.
robot --outputdir testresults/ requestTest.robot &
robotmetrics -M outputReportMetrics.html --inputpath ./testresults/ --output output.xml --log log.html
-
Go to Post-build Actions and click on Add build steps. Select "Publish robot framework test results".
-
Add testresults in directory and outputReportMetrics.html on Other files to copy box. CLick Save.
- After build is complete, click on Robot results.
- Click on Original result files.
- Open "outputReportMetrics.html" report.
If you want to configure the email notification in each build to send to the concern team member, we can achieve it through Jenkins. For this, please follow below steps for configuring.
-
Adding Plugin and Configuring mail server.
- We need the "Email extension Plugin" to install in jenkins. For this, Go to "Manage plugins" in left bar and click on "plugin Manager". You will see the horizontal bar, click on available and type "Email extension Plugin" on search bar. Install the plugin without restart.
- You need to configure the smtp server. Go to Manage Jenkins and click on configure system.
- Search for "Extend" and you will land to email configure page. Add All the information as highlighted. i.e
- Enter your smtp server name. For example I have entered google. You can check this site for more information on other smtp server.
- Click “Use SMTP Authentication” and enter required information.
- Enter the similar information in E-mail notifications. You can check Check “Test configuration by sending test e-mail”. Click “Test configuration” to send test email.
But first, we need to set 'Less secure app' ON. You can open email and go to https://myaccount.google.com/lesssecureapps and Set ON for Less secure app.- 'Less secure app' is deprecated by Google, so we have to set App password. Go to https://myaccount.google.com/security, and turn ON 2-step verification. Then go to https://myaccount.google.com/apppasswords which should allow you to set up application specific passwords. *
- Click “Save” in the bottom of the page
-
Go to Post-build Actions tab and click on "Add post build actions" list menu. You will see Editable email notification, click on that.
-
Now, you will see some information you can input for customizing the email.
- Add the EmailID in Project from to show from where you are going to send the email. Similar to the recipient list. You can add customize message as shown.
- You can attach output result file to the message through attachment section.
- Go to Advance Setting as below for adding the recipient.
- On the trigger section, click on Add and add Recipient list.
- Click "Add Trigger", and select "Always" to add to Recipient list.
-
Click Apply and Save.
-
Click Build Now and enjoy your day.
If you get an error below while opening html. Please follow the steps.
- Try enabling javascript for browser. example for chrome.
- If that doesn't work :
- Go to C:\Program Files (x86)\Jenkins
- edit jenkins.xml file and add below code snippet in the file removing the existing one.
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dhudson.model.DirectoryBrowserSupport.CSP="" -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>