GithubHelp home page GithubHelp logo

nbro10 / code-coverage-api-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jenkinsci/code-coverage-api-plugin

0.0 0.0 0.0 2.46 MB

Jenkins Code Coverage API Plugin

License: MIT License

Shell 0.12% JavaScript 3.84% Java 92.32% XSLT 2.07% CSS 0.40% HTML 1.24%

code-coverage-api-plugin's Introduction

Jenkins Code Coverage Plug-in

Gitter Jenkins Plugin Installs Jenkins GitHub Actions Codecov

This Jenkins plugin integrates and publishes multiple coverage report types. It has been developed during GSoC 2018.

Features

  • Pipeline support
  • Modernized coverage chart
  • Coverage trend
  • Source code navigation
  • Parallel execution in pipeline support
  • Reports combining
  • REST API
  • Failed conditions and flexible threshold setting
  • Other small features

Supported Coverage Formats

Embedded

Other plugins as an Extension of Code Coverage API plugin

Release Notes

See the GitHub Releases.

How to Use it

1. Configure your coverage tool to generate reports

Cobertura based coverage

Configure Maven to generate Cobertura coverage reports:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <formats>
                    <format>xml</format>
                </formats>
                <check/>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>cobertura</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

More information about Cobertura.

JaCoCo based coverage

Configure Maven to generate JaCoCo coverage reports:

<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>report</id>
                    <phase>package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

More Information about JaCoCo.

llvm-cov based coverage

Use llvm-cov to generate JSON format report:

$ llvm-cov export -instr-profile /path/to/foo.profdata /path/to/foo

More Information llvm-cov.

2. (Optional) Install Jenkins plugins which implement Code Coverage API plugin (cobertura-plugin, llvm-cov-plugin).

3. Enable "Publish Coverage Report" publisher in the Post-build Actions.

4. Add your coverage tool adapter and specify reports path.

alt text

5. (Optional) Use the forensics-api plugin to discover the reference build that is used to compute a delta report of the coverage results.

6. (Optional) Specify Thresholds of each metrics in global or adapter level.

7. (Optional) Specify Source code storing level to enable source code navigation.

alt text

Pipeline example

We also support pipeline configuration, you can generate pipeline code in Jenkins Snippet Generator.

publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')]

You can also use jacoco instead of jacocoAdapter if you didn't install Jacoco-Plugin.

Parallel Pipeline Support

We support parallel pipeline. You can call the Code Coverage API plugin in different branches like this:

node {
    parallel firstBranch: {
        publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')]
}, secondBranch: {
        publishCoverage adapters: [jacocoAdapter('jacoco.xml')]
    }
}
Reports Combining Support

You can add tag on publishCoverage and Code Coverage API plugin will combine reports have same tag:

node {
    parallel firstBranch: {
        publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')], tag: ‘t’
}, secondBranch: {
        publishCoverage adapters: [jacocoAdapter('jacoco.xml')], tag: ‘t’
    }
}
Merging Reports

There is also a possibility to merge multiple reports (e.g. from multiple xml files) into one using the mergeToOneReport option with an ant-style path pattern. All reports found by the adapter will then be combined into a single report:

publishCoverage adapters: [jacocoAdapter(mergeToOneReport: true, path: '**/*.xml')]

REST API

We provide a REST API to retrieve coverage data:

  • Coverage result: …​/{buildNumber}/coverage/…​/result/api/\{json|xml\}?depth={number}
  • Trend result: …​/{buildNumber}/coverage/…​/trend/api/\{json|xml\}?depth={number}
  • Coverage result of last build: …​/{buildNumber}/coverage/…​/last/result/api/\{json|xml\}?depth={number}
  • Trend result of last build: …​/{buildNumber}/coverage/…​/last/trend/api/\{json|xml\}?depth={number}

Note: The larger the number, the deeper of coverage information can be retrieved.

code-coverage-api-plugin's People

Contributors

afkbrb avatar bgreen1005 avatar bleibdirtroy avatar bncbhm avatar ccfenner avatar cizezsy avatar daniel-beck avatar dependabot[bot] avatar farrrb avatar fedepell avatar fo-code avatar garethjevans avatar godin avatar jenkinsci-cert-ci avatar jglick avatar kamatsuoka avatar markewaite avatar medianick avatar mrginglymus avatar notmyfault avatar oleg-nenashev avatar phil9909 avatar recampbell avatar simonsymhoven avatar stefanspieker avatar tempora-mutantur avatar timja avatar tinyzzh avatar uhafner avatar xiongkezhi 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.