jenkins integrate findBugs and generate report

The company uses jenkins as a continuous construction tool, because it needs to automate construction, compilation, code walkthrough, and packaging. Introduce today

Experience with jenkins integrating findbugs.

1. First enter the jenkins plugin management page and download the findbugs plugin on the way



 2. Create a new maven project, take findbugs-scan as an example



 3. Then fill in the relevant information of the code base on the "Source Code Management" tab



 

4. Fill in the build command in the "Build Environment" tab

clean compile -Dmaven.test.skip=true  findbugs:findbugs site

If the site command is not added, the report will not be generated in jenkins



 5. Fill in post-build operations, such as sending emails to notify stakeholders




 6. Project pom.xml configuration

  First add the plugin configuration in the pom

 

<build>  
   <plugins>
       <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                     <threshold>High</threshold>
                     <effort>Default</effort>
                     <findbugsXmlOutput>true</findbugsXmlOutput>
                     <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
                     <xmlOutput>true</xmlOutput>
                     <formats><format>html</format></formats>
                     <findbugsXmlOutputDirectory>target/site</findbugsXmlOutputDirectory>
                </configuration>
             </plugin>
   </plugins>
</build>
 Then add the reporting configuration

 

 

<build>
</build>
<reporting>
        <plugins>
               <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>findbugs-maven-plugin</artifactId>
                      <version>3.0.1</version>
                      <configuration>
                      <xmlOutput>true</xmlOutput>
                      <!-- Optional directoryto put findbugs xdoc xml report -->
                      <!--<xmlOutputDirectory>target/site</xmlOutputDirectory>-->
                      <findbugsXmlOutput>true</findbugsXmlOutput>
                      <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
                      </configuration>
               </plugin>
        </plugins>
</reporting>
   If the reporting configuration is not added, the report cannot be generated, and the xml file report can only be viewed in target/site, but not in jenkins.

 

 

7. After the build, you can see the report, as follows:




 

 

 

8. If you need to see a more detailed report, you can view the Maven-generated site



 

Click in to see a more detailed report, including error descriptions and solutions, and you can also integrate static code analysis plugins such as PMD.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326289767&siteId=291194637