jenkins插件findbugs+pmd+checkstyle结合sonar与maven(java环境代码质量和代码规范管理)...
一、下载jdk并安装(最好jdk官网下载解压安装的)
二、下载maven并安装maven
三、安装jenkins及插件
安装checkstyle、pmd、findbugs、maven、sonar等相关插件
四、设置全局变量
五、测试文件下载
使用 alibaba 的 fastjson 来演示:
下载: https://github.com/alibaba/fastjson/archive/master.zip
配置svn服务并把测试文件的内容放入svn中
六、配置jenkins
#测试的svn地址
七、配置pom.xml文件
在pom.xml文件中添加以下内容
vim pom.xml
<project ...><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding></properties><!-- ...... --><reporting><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>findbugs-maven-plugin</artifactId><version>3.0.4</version><configuration><xmlOutput>true</xmlOutput><findbugsXmlOutput>true</findbugsXmlOutput><findbugsXmlWithMessages>true</findbugsXmlWithMessages></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-checkstyle-plugin</artifactId><version>2.17</version><configuration><linkXRef>false</linkXRef><failsOnError>true</failsOnError><consoleOutput>true</consoleOutput><configLocation>checkstyle.xml</configLocation></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-pmd-plugin</artifactId><version>3.7</version><configuration><linkXref>false</linkXref></configuration></plugin></plugins></reporting> </project>
修改后的文件
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.50-SNAPSHOT</version><packaging>jar</packaging><name>fastjson</name><description>Fastjson is a JSON processor (JSON parser + JSON generator) written in Java</description><url>https://github.com/alibaba/fastjson</url><inceptionYear>2012</inceptionYear><properties><junit.version>4.12</junit.version><gpg.skip>true</gpg.skip><javadoc.skip>false</javadoc.skip><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><jdk.version>1.5</jdk.version></properties><scm><url>https://github.com/alibaba/fastjson</url><connection>scm:git:https://git@github.com/alibaba/fastjson.git</connection></scm><repositories><repository><id>local-file</id><url>file://${basedir}/lib/</url><layout>default</layout></repository></repositories><organization><name>Alibaba Group</name><url>https://github.com/alibaba</url></organization><developers><developer><id>wenshao</id><name>wenshao</name><email>szujobs@hotmail.com</email></developer><developer><id>axmanwang</id><name>axmanwang</name><email>iamaxman@hotmail.com</email></developer><developer><id>kimmking</id><name>kimmking</name><email>kimmking@163.com</email></developer><developer><id>Victor Zeng</id><name>Victor Zeng</name><email>Victor.Zxy@outlook.com</email></developer><developer><id>Neil Dong</id><name>Neil Dong</name><email>email_dsl@163.com</email></developer><developer><name>李恒名</name><url>https://github.com/lihengming/</url><email>89921218@qq.com</email></developer></developers><licenses><license><name>Apache 2</name><url>http://www.apache.org/licenses/LICENSE-2.0.txt</url><distribution>repo</distribution><comments>A business-friendly OSS license</comments></license></licenses><build><extensions><extension><groupId>org.apache.maven.wagon</groupId><artifactId>wagon-webdav</artifactId><version>1.0-beta-2</version></extension></extensions><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.5.1</version><configuration><encoding>UTF-8</encoding><source>${jdk.version}</source><target>${jdk.version}</target></configuration><dependencies><dependency><groupId>org.codehaus.plexus</groupId><artifactId>plexus-compiler-javac</artifactId><version>2.7</version></dependency></dependencies></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><executions><execution><id>attach-sources</id><goals><goal>jar-no-fork</goal></goals></execution></executions><configuration><attach>true</attach></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><configuration><includes><include>**/bvt/**/*.java</include></includes></configuration></plugin><plugin><artifactId>maven-javadoc-plugin</artifactId><executions><execution><id>attach-javadoc</id><goals><goal>jar</goal></goals></execution></executions><configuration><skip>${javadoc.skip}</skip><show>public</show><charset>UTF-8</charset><encoding>UTF-8</encoding><docencoding>UTF-8</docencoding><links><link>http://docs.oracle.com/javase/6/docs/api</link></links></configuration></plugin><plugin><artifactId>maven-gpg-plugin</artifactId><configuration><skip>${gpg.skip}</skip></configuration><executions><execution><id>sign-artifacts</id><phase>verify</phase><goals><goal>sign</goal></goals></execution></executions></plugin></plugins></build><dependencies><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>javax.ws.rs</groupId><artifactId>javax.ws.rs-api</artifactId><version>2.0.1</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-transports-http</artifactId><version>3.1.2</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-frontend-jaxrs</artifactId><version>3.1.2</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-websocket</artifactId><version>4.3.7.RELEASE</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>4.3.7.RELEASE</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-messaging</artifactId><version>4.3.7.RELEASE</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>org.springframework.data</groupId><artifactId>spring-data-redis</artifactId><version>1.8.6.RELEASE</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>com.squareup.retrofit2</groupId><artifactId>retrofit</artifactId><version>2.1.0</version><scope>provided</scope></dependency><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>3.6.0</version><scope>provided</scope></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-spring-web</artifactId><version>2.6.1</version><scope>provided</scope><optional>true</optional></dependency><dependency><groupId>io.javaslang</groupId><artifactId>javaslang</artifactId><version>2.0.6</version><scope>provided</scope></dependency><dependency><groupId>org.glassfish.jersey.core</groupId><artifactId>jersey-common</artifactId><version>2.23.2</version><scope>provided</scope></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-server</artifactId><version>8.1.8.v20121106</version><scope>test</scope><optional>true</optional></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-webapp</artifactId><version>8.1.8.v20121106</version><scope>test</scope><optional>true</optional></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>${junit.version}</version><scope>test</scope></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.9.0</version><scope>test</scope></dependency><dependency><groupId>com.fasterxml.jackson.module</groupId><artifactId>jackson-module-afterburner</artifactId><version>2.9.0</version><scope>test</scope></dependency><dependency><groupId>com.fasterxml.jackson.module</groupId><artifactId>jackson-module-kotlin</artifactId><version>2.9.0</version><scope>test</scope></dependency><dependency><groupId>cglib</groupId><artifactId>cglib-nodep</artifactId><version>2.2.2</version><scope>test</scope></dependency><dependency><groupId>com.fasterxml.jackson.jaxrs</groupId><artifactId>jackson-jaxrs-json-provider</artifactId><version>2.8.7</version><scope>test</scope></dependency><dependency><groupId>com.googlecode.json-simple</groupId><artifactId>json-simple</artifactId><version>1.1.1</version><scope>test</scope></dependency><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>1.4</version><scope>test</scope></dependency><dependency><groupId>net.sf.json-lib</groupId><artifactId>json-lib</artifactId><version>2.4</version><classifier>jdk15</classifier><scope>test</scope></dependency><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>2.6.2</version><scope>test</scope></dependency><dependency><groupId>net.minidev</groupId><artifactId>json-smart</artifactId><version>2.2.1</version><scope>test</scope></dependency><dependency><groupId>org.clojure</groupId><artifactId>clojure</artifactId><version>1.5.1</version><scope>test</scope></dependency><dependency><groupId>org.codehaus.groovy</groupId><artifactId>groovy</artifactId><version>2.1.5</version><scope>test</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>4.3.7.RELEASE</version><scope>test</scope></dependency><dependency><groupId>org.javassist</groupId><artifactId>javassist</artifactId><version>3.18.0-GA</version><scope>test</scope></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-rs-client</artifactId><version>3.1.2</version><scope>test</scope></dependency><dependency><groupId>org.springframework.data</groupId><artifactId>spring-data-commons-core</artifactId><version>1.4.1.RELEASE</version><scope>test</scope></dependency><dependency><groupId>org.glassfish.jersey.containers</groupId><artifactId>jersey-container-servlet</artifactId><version>2.23.2</version><scope>test</scope></dependency><dependency><groupId>org.glassfish.jersey.core</groupId><artifactId>jersey-client</artifactId><version>2.23.2</version><scope>test</scope></dependency><dependency><groupId>org.glassfish.jersey.test-framework.providers</groupId><artifactId>jersey-test-framework-provider-jdk-http</artifactId><version>2.23.2</version><scope>test</scope></dependency><dependency><groupId>org.glassfish.jersey.media</groupId><artifactId>jersey-media-json-jackson</artifactId><version>2.23.2</version><scope>test</scope></dependency><dependency><groupId>com.jsoniter</groupId><artifactId>jsoniter</artifactId><version>0.9.8</version><scope>test</scope></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.4</version><scope>test</scope></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>5.2.10.Final</version><scope>test</scope></dependency><dependency><groupId>com.jayway.jsonpath</groupId><artifactId>json-path</artifactId><version>2.3.0</version><scope>test</scope></dependency><dependency><groupId>org.jetbrains.kotlin</groupId><artifactId>kotlin-stdlib</artifactId><version>1.1.3-2</version><scope>test</scope></dependency><dependency><groupId>org.jetbrains.kotlin</groupId><artifactId>kotlin-reflect</artifactId><version>1.1.3-2</version><scope>test</scope></dependency><dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-web</artifactId><version>4.2.3.RELEASE</version><scope>test</scope></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-collections4</artifactId><version>4.1</version><scope>test</scope></dependency><dependency><groupId>org.mockito</groupId><artifactId>mockito-all</artifactId><version>1.10.19</version><scope>test</scope></dependency><dependency><groupId>org.powermock</groupId><artifactId>powermock-module-junit4</artifactId><version>1.6.6</version><scope>test</scope></dependency><dependency><groupId>com.diffblue</groupId><artifactId>deeptestutils</artifactId><version>1.1.0</version><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.14.4</version><scope>test</scope></dependency><dependency><groupId>org.openjdk.jmh</groupId><artifactId>jmh-core</artifactId><version>1.21</version><scope>test</scope></dependency><dependency><groupId>org.openjdk.jmh</groupId><artifactId>jmh-generator-annprocess</artifactId><version>1.21</version><scope>test</scope></dependency><dependency><groupId>org.springframework.security.oauth</groupId><artifactId>spring-security-oauth2</artifactId><version>2.3.3.RELEASE</version><exclusions><exclusion><artifactId>commons-codec</artifactId><groupId>commons-codec</groupId></exclusion><exclusion><artifactId>jackson</artifactId><groupId>jackson-mapper-asl</groupId></exclusion><exclusion><artifactId>jackson</artifactId><groupId>jackson-core-asl</groupId></exclusion></exclusions><scope>test</scope></dependency></dependencies><profiles><profile><id>travis</id><activation><property><name>env.TRAVIS</name><value>true</value></property></activation><build><plugins><plugin><!-- for codecov.io --><!-- config example: https://github.com/codecov/example-java --><!-- plugin docs: http://eclemma.org/jacoco/trunk/doc/ --><groupId>org.jacoco</groupId><artifactId>jacoco-maven-plugin</artifactId><version>0.7.6.201602180812</version><executions><execution><goals><goal>prepare-agent</goal></goals></execution><execution><id>report</id><phase>test</phase><goals><goal>report</goal></goals></execution></executions></plugin></plugins></build></profile></profiles><reporting><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>findbugs-maven-plugin</artifactId><version>3.0.4</version><configuration><xmlOutput>true</xmlOutput><findbugsXmlOutput>true</findbugsXmlOutput><findbugsXmlWithMessages>true</findbugsXmlWithMessages></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-checkstyle-plugin</artifactId><version>2.17</version><configuration><linkXRef>false</linkXRef><failsOnError>true</failsOnError><consoleOutput>true</consoleOutput><configLocation>checkstyle.xml</configLocation></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-pmd-plugin</artifactId><version>3.7</version><configuration><linkXref>false</linkXref></configuration></plugin></plugins></reporting> </project>
pom.xml
###配置maven编译参数
package -Dmaven.test.skip=true findbugs:findbugs checkstyle:checkstyle pmd:pmd
##将findbugs等插件打勾
八、配置sonar参数
参数
sonar.host.url=http://localhost:9000 #建议公网ip sonar.sourceEncoding=UTF-8 ##字符集 sonar.projectKey=test-key #自定义的key sonar.projectName=test ##自定义名称 sonar.projectVersion=1.0 ##自定义版本 sonar.sources=/mnt/fastjson-master ##代码目录 sonar.java.binaries=/mnt/fastjson-master ##java语句必须制定
九、sonar设置
登录admin账号 SCM设为True
十、结果
十一、设置邮件发送信息
转载于:https://www.cnblogs.com/zhangb8042/p/9486843.html
jenkins插件findbugs+pmd+checkstyle结合sonar与maven(java环境代码质量和代码规范管理)...相关推荐
- idea,配置checkstyle 【提高代码质量,检查代码规范的工具 】Checkstyle,FindBugs,PMD,Jtest
idea,配置checkstyle [提高代码质量,检查代码规范的工具 ]Checkstyle,FindBugs,PMD,Jtest 2016年12月15日 14:19:02 common_util ...
- idea 配置checkstyle【提高代码质量,检查代码规范的工具】
下面主要介绍IDEA,如何配置,使用checkstyle 1.CheckStyle插件安装和使用 一,打开settings的plugins,点击查找CheckStyle-IDEA安装,如果查找不到,B ...
- 代码走查工具FindBugs, PMD,CheckStyle
Eclipse安装findBugs插件 在Eclipse中点击Help-Install New SoftWare,输入下面网址添加: http://findbugs.cs.umd.edu/eclips ...
- Devops学习实践(三) jenkins集成findbugs
随着工作的要求,devops作为今年工作的一个重点,由此也引发了自己对于devops相关的工具和技术的学习和实践.基于上述背景,这个系列将逐步的介绍SVN的安装和配置.jenkins安装和配置.rev ...
- 使用Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境
前言 但凡一个略有规模的项目都需要一个持续集成环境的支撑,为什么需要持续集成环境,我们来看一个例子.假如一个项目,由A.B两位程序员来协作开发,A负责前端模块,B负责后端模块,前端依赖后端.A和B都习 ...
- 使用Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境(一)
前言 但凡一个略有规模的项目都需要一个持续集成环境的支撑,为什么需要持续集成环境,我们来看一个例子.假如一个项目,由A.B两位程序员来协作开发,A负责前端模块,B负责后端模块,前端依赖后端.A和B都习 ...
- 优雅!用了这两款插件,我成了整个公司代码写得最规范的码农
同事:你的代码写的不行啊,不够规范啊. 我:我写的代码怎么可能不规范,不要胡说. 于是同事打开我的 IDEA ,安装了一个插件,然后执行了一下,规范不规范,看报告吧. 这可怎么是好,这玩意竟然给我挑出 ...
- ReSharper智能插件,ReSharper分析代码质量
ReSharper智能插件,ReSharper分析代码质量 ReSharper 是 Visual Studio 的智能插件.它配备了一组丰富的功能,包括智能编码辅助.即时错误突出显示和快速纠错.ReS ...
- Docker+Jenkins持续集成环境(3)集成PMD、FindBugs、Checkstyle静态代码检查工具并邮件发送检查结果...
为了规范代码,我们一般会集成静态代码检测工具,比如PMD.FindBugs.Checkstyle,那么Jenkins如何集成这些检查工具,并把检查结果放到构建邮件里呢? 今天做了调研和实现,过程如下 ...
最新文章
- docker build命令详解_Docker 搭建你的第一个 Node 项目到服务器
- 阿里6年32岁程序员:辞职在中小厂干了快两年,我怎么没有职场危机(年龄)?
- linux系统中ntp服务监听端口是,Linux系统下测试UDP端口是否正常监听的办法
- linux ping策略打开_linux ping策略打开_如何在Linux服务器禁止和开启ping包 互联网技术圈 互联网技术圈......
- Django上传文件及分页
- 解决 Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at
- 蘑菇车联打造一体化解决方案,致力产业协同发展
- 2字节取值范围_C语言整数的取值范围以及数值溢出
- RDKit | 基于RDKit的随机SMILES的生成
- 大型计算机grads使用,win10中GRADS出现FAST_CWD pointer错误的详细解决方法
- 程序员必备之电脑护眼模式设置
- requests.get为什么得到的内容和查看源文件不一样?
- (转帖)SpringBoot自定义Starter
- win10应用商店linux_解决win10应用商店“由于公司策略 此应用已被阻止”的方法...
- 基于TCP的在线聊天室
- centos 6 安装 net-speeder
- 计算机视觉、模式识别、机器学习牛人主页
- SSM框架学习(一)————SSM框架简介
- 计算机怎样看配置高低,笔记本电脑配置怎么看 查询配置参数高低教程
- 使用化学烧伤创建自定义的详细木材燃烧图案
热门文章
- HDU 5112 A Curious Matt 水题
- 一步步学习SPD2010--第十一章节--处理母版页(7)--管理Content Placeholders
- sql 日期概念理解中的一些测试
- 七天学习计划_c#_[1]泛型类(还有六天,明天继续写!)
- 没有匹配 if 的非法 else_求求你,别再写这么多if...else...了
- java数组与对象例题,Java的字符串和数组是以对象的形式出现的。()
- pbp 读取 mysql数据_SqlAlchemy 中操作数据库时session和scoped_session的区别(源码分析)...
- VMware安装Win7虚拟机
- MFC指定位置画位图
- pointnet 结果可视化_PointNet论文复现及代码详解