free counter statistics

Jenkins Reporting


Introduction to Jenkins Reporting

Jenkins’s reporting is a chunk of knowledge. It is absolutely accountable for representing the info that’s investigated, or one has noticed in a structured and graphical method. It has an in depth description of the Jenkins job. The objective of Jenkin’s reporting is in a single sense simple and self-evident in order that it’s straightforward to know for enterprise or Jenkins customers. Jenkins Reporting has a mixture of various functions to wrap info and drafted in regards to the jobs. It is an in depth evaluation or reflection of the knowledge which is generated whereas operating the job. As an output, Jenkin’s job offers detailed info and delivers them to Jenkin’s consumer in a well-aligned and descriptive type with respect to the topic.

Let’s take an instance the place my group must configure the JUnit take a look at for the code. Also, in search of a JUnit report generated in xml format with the assistance of Jenkins.

As per these use case, we’re following the beneath steps:-

Jenkins Build instruments sometimes automate the next actions for this give use instances:-

  • Organize project-specific recordsdata
  • Compile the supply code
  • Generates documentation for the supply code
  • Runs Junit and integration take a look at instances
  • Generate the JUnit take a look at report

Why JUnit?

Junit is a framework for automating unit testing; every time we add new options to the software program, we have to retest and write Junit take a look at instances with all functionalities.

So, please discover the beneath configurations to set the JUnit take a look at report in xml format:-

Log in to the Jenkins account with admin credentials and click on the Manage Jenkins hyperlink:-

Now, you may see the display screen beneath. Clicked into handle plugins and confirm if the JUnit plugin was put in correctly.

Jenkins Reporting output 2

We can confirm whether or not the Junit plugins is put in efficiently or not by navigating to the put in tab.

Jenkins Reporting output 3

Post profitable installations of ju*9/1nit plugins, Goto the job by clicking the Jenkins header. Once you’re navigated to your job click on on to the configure hyperlink

Jenkins Reporting output 4

Select the supply code administration and outline the repository particulars for the code the place the code is on the market. Since we’re producing the report based mostly on the maven challenge, please discover the beneath configuration in pom.xml for the junit take a look at:-

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<model>4.12</model>
<scope>take a look at</scope>
</dependency>

Jenkins Reporting output 5.1

Jenkins Reporting output 5.2

Just we have to run the construct job, which is produced xml file, after which we are able to present the trail. The path means the trail of the xml that may produce the JUnit report after the take a look at case is executed.

For this maven consumer, it makes use of the surefire plugins for JUnit testing.

In Post-build Actions, click on on Add post-build motion, choose “Publish JUnit test result report.” We should specify the listing below Test report XMLs the place all of your xml stories are getting generated. For i.e. : goal/surefire-reports. Hence specify the trail as stories/*.xml to incorporate all of the xml recordsdata current contained in the stories. So, we’ve got specified the placement to the client workspace; inside this workspace, Jenkins will search for the stories folder, and contained in the stories folder, it would search for the xml recordsdata. Apply and Save the adjustments.

Jenkins Reporting output 6

Once the construct has been accomplished, by following the trail talked about within the beneath screenshot, you may get the XML used to comprise the report and summarize the identical. Next, we have to redirect the goal folder the place mave produces binaries or jar or ear put up profitable construct.

output 7

Need to configure goal/surefire stories into the publish JUnit take a look at end result report part. This is principally a path for Test report XML.

output 8

Navigate to your job in Jenkins, you will notice any hyperlink to the stories, however when you do a Build Now, you’d see a brand new hyperlink generated “Latest Test Result” and a chart exhibiting the take a look at failures.

output 9

We can see the xml which incorporates the JUnit report the place all of the go and fail data obtainable based mostly on the take a look at instances.

output 10.1

output 10.2

Please discover the take a look at code beneath for which the Junit report has been generated:-

import org.springframework.boot.SpringUtility;
import org.springframework.boot.autoconfigure.SpringBootUtility;
@SpringBootUtility
public class SpringBootTestExampleApplication
{
public static void foremost(String[] args)
{
SpringUtility.run(SpringBootTestExampleApplication.class, args);
}
}

Please discover the pattern xml code the place normally the take a look at case is anticipated.

import org.junit.jupiter.api.Test;
import org.springframework.boot.take a look at.context.SpringBootTest;
@SpringBootTest
class SpringBootTestExampleApplicationTests
{
@Test
void contextLoads()
{
}
}

Please discover the pom.xml code type the place the report generated

<?xml model="1.0" encoding="UTF-8"?>
<challenge xmlns=http://maven.apache.org/POM/4.0.0 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<dad or mum>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<model>2.2.2.BUILD-SNAPSHOT</model>
<relativePath/><!-- lookup dad or mum from repository -->
</dad or mum>
<groupId>com.level</groupId>
<artifactId>spring-boot-example</artifactId>
<model>0.0.1-SNAPSHOT</model>
<title>spring-boot-example</title>
<description>Demo challenge for Spring Boot</description>
<properties>
<java.model>1.8</java.model>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<model>2.2.1.RELEASE</model>
<sort>pom</sort>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>take a look at</scope>
<exclusions>
<exclusion>
<groupId>org.junit.classic</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<construct>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</construct>
<repositories>
<repository>
<id>spring-milestones</id>
<title>Spring Milestones</title>
<url>https://repo.spring.io/milestone</url>
</repository>
<repository>
<id>spring-snapshots</id>
<title>Spring Snapshots</title>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<title>Spring Milestones</title>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<title>Spring Snapshots</title>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</challenge>

Please discover the few factors beneath to know pom.xml:-

groupId: This displays the consumer’s info for whom we’re growing this challenge. Technically we are able to put any worth on this, however we observe the next conference.
By conference, it must be an organization title or reverse area title of the corporate as follows

<groupId>xxxxxx</groupId>

artifactId: This represents the challenge title, some examples

<artifactId>xxxxxxx</artifactId>

packaging: This represents the software program bundle format that must be created by maven, a number of examples

<packaging>warfare</packaging>

model: present model of the challenge

<model>1.7.2</model>

Recommended Articles

This is a information to Jenkins Reporting. Here we talk about the instance to configure the JUnit take a look at for the code and a JUnit report which is generated in xml format with the assistance of Jenkins. You may take a look on the following articles to be taught extra –

  1. Jenkins Email Notification
  2. Uses of Jenkins
  3. Jenkins Alternatives
  4. Jenkins Plugins

The put up Jenkins Reporting appeared first on EDUCBA.



Source link

Leave a Comment