-
安装 sonar ,新建一个用户 sonar,并创建 token
-
jenkins 系统安装 sonar scanner 插件,配置 token
-
修改项目属性
[X] Prepare SonarQube Scanner environment
Server authentication token [sonar]
- maven 编译命令
mvn clean package -U -Dmaven.test.skip=true sonar:sonar
- gradle 编译命令
gradle build -x test sonarqube
sonar:sonar sonarqube
sonar 集成 p3c
git clone git@github.com:caowenliang/sonar-pmd-p3c.git
cd sonar-pmd-p3c
mvn clean install -Dmaven.test.skip=true
cp sonar-pmd-plugin/target/sonar-pmd-plugin-3.2.1.jar /app/sonar/extensions/plugins/
如果编译出现问题提示文件太大,需要 vim sonar-pmd-plugin/pom.xml 改为 <maxsize>80000000</maxsize>
sonar.service
[Unit]
Description=sonar server daemon
After=syslog.target network.target
[Service]
Environment="JAVA_HOME=/usr/java/latest"
#Type=forking
Type=simple
WorkingDirectory=/home/app
PermissionsStartOnly=true
#ExecStartPre=/bin/mkdir -p /app/logs/ /logs /app/file /app/data /usr/local/apache-tomcat /app/jar /app/tmp
ExecStart=/bin/bash /app/sonar/bin/linux-x86-64/sonar.sh console
ExecReload=/bin/kill -s HUP
ExecStop=/bin/kill -s QUIT
User=app
Group=app
LimitNOFILE=1048576
LimitNPROC=65535
Restart=on-failure
[Install]
WantedBy=multi-user.target
网友评论