Skip to content

How To Publish ExtentReport Using Jenkins

ExtentReport

Jenkins is a powerful application that allows continuous integration and continuous delivery of projects, regardless of the platform we are working on. It is free and can be integrated with a number of testing and deployment technologies. In this article, we will see, how we can execute our tests on slave agents and publish ExtentReport Using Jenkins.

Jenkins-installation:

Jenkins installation can be done in multiple ways. We can install Jenkins using Docker or AWS as well.

Prerequisite:

1)JDK installation and path configuration.

Jenkins Installation on Windows

Download and install Jenkins from Here. Unzip it and complete the configuration and installation. After successful installation check port 8080. Open the web browser and type “localhost:8080”.

Jenkins Installation on Mac

First, install Homebrew. Then install Jenkins using the brew command.

brew install jenkins-lts

After successful installation start the server using the below-mentioned command.

brew services start jenkins-lts

Jenkins Installation Using Docker

Docker is a popular platform widely used for building, testing and deploying an application using OS-level virtualization in the form of containers. In this article, I will be using Jenkins docker image to set up Jenkins.

Prerequisite:

Install and set up Docker.

Once docker is installed on your machine the next step is to create a Jenkins server on docker. Follow the below-mentioned steps for Jenkins installation and configuration.

1)Pull a stable image of Jenkins from the docker hub.

docker pull jenkins/jenkins:lts

2)Create a Jenkins directory preferably not in the project directory.

mkdir jenkins

3)Navigate to the directory and execute the below command to map the Jenkins container port to our local machine port.

docker run -p 8080:8080 -p 50000:50000 -v “$PWD/jenkins:/var/jenkins_home” jenkins/jenkins:lts

4)Copy the Jenkins password and save it for future reference.

5)Install all the available plugins and complete the Jenkins setup.

6) Set up Username and password for Jenkins dashboard.

Once setup is successful, you will navigate to Jenkins Login Screen. Enter your username and password and login into the dashboard.

Configure Slave Node:

Jenkins uses a master-slave architecture to configure distributed builds. In this architecture, Master and Slave nodes communicate through TCP/IP protocol. The main Jenkins server acts as the Master node that manages slaves. A slave is a Java executable that runs on a remote machine. We can have any number of agent nodes and slave nodes.

To Configure Node, select “Manage Jenkins -> Manage Nodes And Clouds-> New Node” to create a new node.

Enter NodeName, select permanent agent, and click ok.

Agent Node setup
AgentNode

In the next screen, we need to provide a number of executors, the Remote Root directory, and the launch method. You can provide any preferable path to the Remote Root directory where you want to keep your agent machine data. We are going to use ‘Launch agent by connecting it to controller’ as the launch method. Click on save.

Slave node setup
Jenkins Master Slave setup

Click on slave.jar. A file named slave-agent.jnlp will be downloaded. Copy the command visible on the screen as ‘Run from agent command line’, Navigate to the folder from your cmd or terminal where the jar file is downloaded, and execute the command. The slave node is successfully set up and available.

Manage Plugins:

Go To Dashboard–>Manage Jenkins–>Manage Plugins, Type HTML Publisher Plugin, select and click on install without restart.

Create Freestyle Project:

Once Plugin is installed and executor nodes configured the next step is creating a project. To create a project in Jenkins, go to Dashboard–>New Item–>Freestyle Project, provide a name to the project and click on ok.

Configuration for publishing extent report:

1)Select git as source code management and provide your repository URL. Choose credentials as none if it is a public repository and mention the Branch specifier as “*/*”

Jenkins SCM configuration

2)Go to the Build Section, click on add build step, and select “invoke top-level maven target” from the dropdown. Type ‘clean install’ in the goals section. This maven command will clean previously complied binaries and build and install the JARS defined in our project’s pom.xml file.

3)Go to post-build actions, and click on add post-build steps. choose Publish HTML Reports.

Provide the relative path where extent reports are stored and provide the exact name of the report in the index page option. Give the report title and click on Apply and save.

Jenkins Post build actions

4)Now the project is configured successfully. Navigate to the project and click on Build Now. The build is triggered and after successful execution, you will see the HTML Report option in the project workspace. Click on it and you will navigate to this beautiful report.

Publish ExtentReport Using Jenkins
ExtentReport

Tip: If you don’t see the Report UI intact then you need to configure a simple Groovy script. For that go to Dashboard–>Manage Jenkins–>Script Console and add the script as:

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")