Giter Club home page Giter Club logo

jx-app-jacoco's Introduction

jx-app-jacoco

jx-app-jacoco provides a means for transferring a Jacoco XML code coverage report from a Jenkins X build to a Fact in the PipelineActivity custom resource.

You must have a Jenkins X cluster to install and use the jx-app-jacoco app. If you do not have a Jenkins X cluster and you would like to try it out, the Jenkins X Google Cloud Tutorials is a great place to start.

Installation

Using the jx command line tool, run the following command:

$ jx add app jx-app-jacoco --repository "http://chartmuseum.jenkins-x.io"

NOTE: The syntax of this command is evolving and will change.

Upon successful installation, you should see jx-app-jacoco in the list of pods (kubectl get pods) running in your cluster - it will be called jx-app-jacoco-jx-app-jacoco.

NOTE: The name repetition is a typical pattern in Helm.

Usage

The current usage of jx-app-jacoco is limited to Maven projects. You must configure the build section of your Maven POM file for Jacoco to generate an XML report in addition to the default jacoco.exec file.

Example Maven POM file:

<build>
  <plugins>
     <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
     </plugin>
     <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.2</version>
        <executions>
           <execution>
              <id>default-prepare-agent</id>
              <goals>
                 <goal>prepare-agent</goal>
              </goals>
           </execution>
           <execution>
              <id>prepare-xml-report</id>
              <goals>
                 <goal>report</goal>
              </goals>
              <phase>verify</phase>
           </execution>
        </executions>
     </plugin>
 </plugins>
</build>

NOTE: We have an open issue to not have to generate the XML report in the project.

Ensure that your Jenkinsfile includes the following command, so the Jacoco XML report is stored for later retrieval by this app.

sh "jx step stash --pattern=target/site/jacoco/jacoco.xml --classifier=jacoco"

Example JenkinsFile build steps:

sh "mvn install"
sh "jx step stash --pattern=target/site/jacoco/jacoco.xml --classifier=jacoco"

Jacoco code coverage facts will now be stored in the PipelineActivity custom resource for each build.

$ kubectl get act -o yaml <org>-<repo>-pr-<pull request number>-<build-number>
factType: jx.coverage
id: 0
measurements:
- measurementType: percent
  measurementValue: 6
  name: Instructions-Coverage
- measurementType: percent
  measurementValue: 7
  name: Instructions-Missed
- measurementType: percent
  measurementValue: 13
  name: Instructions-Total
- measurementType: percent
  measurementValue: 2
  name: Lines-Coverage
- measurementType: percent
  measurementValue: 3
  name: Lines-Missed
- measurementType: percent
  measurementValue: 5
  name: Lines-Total
- measurementType: percent
  measurementValue: 2
  name: Complexity-Coverage
- measurementType: percent
  measurementValue: 2
  name: Complexity-Missed
- measurementType: percent
  measurementValue: 4
  name: Complexity-Total
- measurementType: percent
  measurementValue: 2
  name: Methods-Coverage
- measurementType: percent
  measurementValue: 2
  name: Methods-Missed
- measurementType: percent
  measurementValue: 4
  name: Methods-Total
- measurementType: percent
  measurementValue: 2
  name: Classes-Coverage
- measurementType: percent
  measurementValue: 0
  name: Classes-Missed
- measurementType: percent
  measurementValue: 2
  name: Classes-Total

Building from source

The following paragraphs describe how to build and work with the source.

Prerequisites

The project is written in Go, so you will need a working Go installation (Go version >= 1.11.4).

The build itself is driven by GNU Make which also needs to be installed on your system.

Compile the code

$ make linux

After successful compilation the jx-app-jacoco binary can be found in the bin directory.

Run the tests

$ make test

Cleanup

$ make clean

How to contribute

If you want to contribute, make sure to follow the contribution guidelines when you open issues or submit pull requests.

jx-app-jacoco's People

Contributors

daveconde avatar deanesmith avatar hferentschik avatar jenkins-x-bot avatar jglick avatar pmuir avatar rawlingsj avatar vlatombe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.