Java小强个人技术博客站点    手机版
当前位置: 首页 >> 开源 >> Jenkins集成SonarQube

Jenkins集成SonarQube

15110 开源 | 2022-3-4

sonar是一款静态代码质量分析工具,支持Java、Python、PHP、JavaScript、CSS等25种以上的语言,而且能够集成在IDE、Jenkins、Git等服务中,方便随时查看代码质量分析报告。


安装SonarQube Scanner插件

sonar.jpg


添加SonarQube凭证

sonar2.jpg

这个凭证就是安装Sonar时,第一次登录生成的那个token。


Jenkins进行SonarQube配置

Manage Jenkins->Configure System->SonarQube servers


sonar3.jpg



名字随便起,地址就是sonar的地址,token上一步已经配置好,这里直接选择。


Manage Jenkins->Global Tool Configuration


sonar4.jpg


名字随便起,版本默认最新版即可。


项目配置

打开项目,Pre Steps,选择Execute SonarQube Scanner


sonar5.jpg


配置内容如下:

# must be unique in a given SonarQube instance 
sonar.projectKey=web_demo 
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. 
sonar.projectName=web_demo 
sonar.projectVersion=1.0 

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # This property is optional if sonar.modules is set. 
sonar.sources=. 
sonar.exclusions=**/test/**,**/target/** 

sonar.java.source=1.8 
sonar.java.target=1.8 

# Encoding of the source code. Default is default system encoding 
sonar.sourceEncoding=UTF-8


再次点击Build,然后打开sonar,查看审查情况

sonar6.jpg


END

推荐您阅读更多有关于“ 密钥 插件 jenkins sonar 代码审查 ”的文章

上一篇:CentOS7配置RocketMQ集群 下一篇:CentOS安装SonarQube

猜你喜欢

发表评论: