Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
113 lines (86 sloc) 3.98 KB

Providing support for a custom static analysis tool

The most flexible way to add a new static analysis tool to the warnings plug-in is to provide a new custom plugin that contains a Java implementation of the tool.

Create a plugin

The plugin should depend on Jenkins plugin parent pom and on the warnings plugin.

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

    <relativePath />

  <name>[Your Plugin Name]</name>


Create a parser class

Each custom tool requires a parser that will be instantiated to scan the console log (or a report file). The parser must derive from the abstract class IssueParser, or one of the child classes. The following base classes can be used as the base class:

  • AbstractParser: parses an input stream - you have under full control on how to access the input stream.
  • RegexpLineParser: parses all lines of an input stream one by one with a regular expression.
  • FastRegexpLineParser: same as RegexpLineParser, but with additional support to skip lines based on string comparisons.
  • RegexpDocumentParser: parses the whole input stream by reading it into a string and parsing the whole string with a regular expression. This type of parser is quite slow and should only be used if there is no other way.

Please have a look at one of the existing parsers in order to see how to use these base classes.

Register the tool in the warnings plugin

In order to get picked up by the warnings plugin your parser must be registered as an extension. This is achieved by extending from the base class StaticAnalysisTool and registering it using the annotation @Extension at the associated Descriptor class. Typically you do this in Jenkins by adding the descriptor as a static nested class of the StaticAnalysisTool. Here is an example that can be used as a starting point.

package io.jenkins.plugins.analysis.warnings;

import javax.annotation.Nonnull;

import org.kohsuke.stapler.DataBoundConstructor;

import io.jenkins.plugins.analysis.core.model.StaticAnalysisTool;

import hudson.Extension;

 * Provides a parser and customized messages for your tool.
public class YourTool extends StaticAnalysisTool {
    private static final long serialVersionUID = 1L;
    static final String ID = "your-id";

    /** Creates a new instance of {@link YourTool}. */
    public YourTool() {
        // empty constructor required for stapler

    public YourParserClass createParser() {
        return new YourParserClass();

    /** Descriptor for this static analysis tool. */
    public static class Descriptor extends StaticAnalysisToolDescriptor {
        /** Creates the descriptor instance. */
        public Descriptor() {

        public String getDisplayName() {
            return "Your parser name";

Packaging the plugin

You can create a HPI of your plugin by calling mvn clean install. For more details on Jenkins plugin development please see wiki or homepage.

You can’t perform that action at this time.