Jenkins integrated FindBugs plug-in for static code analysis

Source: Internet
Author: User

The installation of findbugs is required for the Jenkins version, so it is necessary to determine whether the current version can be installed findbugs before installation. Currently we are using jenkins1.609.2,Findbugs4.61.

Install the ANALYSIS-CORE.HPI plugin before installing the plugin

Findbugs ( Findbugs.hpi ) can automate code walk-through, be able to prompt for spam code or provide recommendations for code optimization, look for code flaws,

For example: A. database connection not closed;

B. Lack of necessary null check;

C. redundant null check;

D. Excess if post-conditions;

E. The same conditions branch;

F. Duplicate code blocks;

G. Wrong use of "= =";

H. It is recommended that stringbuffer be used instead of string addition;

(1) Jenkins install FindBugs plug-in

Specific installation steps: Enter system management on the main page

Select Plug-in management

Find the plug-in you want to install in the filter and install it

(2) Pom.xml configuration FindBugs plug-in

Because our company project code each module independent development, each module has a pom.xml file, and different modules and dependencies, and each pom.xml is inherited from the base module, so we only need to be configured in the most basic Pom.xml file.

The following is the specific configuration information.

<plugin>

<groupId>org.codehaus.mojo</groupId>

<artifactId>findbugs-maven-plugin</artifactId>

<version>2.5.2</version>

<configuration>

<findbugsXmlOutput>true</findbugsXmlOutput>

<findbugsXmlWithMessages>true</findbugsXmlWithMessages>

<xmlOutput>true</xmlOutput>

</configuration>

</plugin>

(3) After configuration, set findbugs:findbugs in the goals of Jenkins and select Publish findbugs analysis results in the build settings. For our project, we need to skip JUnit's tests so that there are more other configurations. Configuration needs to be configured in each job, not listed here.

(4) Verify the installation of the findbugs.

After the plug-in is installed, and the configuration information is also configured, you can do findbugs verification, we only need to build the project, after the build can see the findbugs run record.

For more information, refer to:

Https://wiki.jenkins-ci.org/display/JENKINS/FindBugs+Plugin

Jenkins integrated FindBugs plug-in for static code analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.