install pgsql and sonarqube
docker run --name postgresqldb -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -d postgres
docker run --name sq --link postgresqldb -e SONARQUBE_JDBC_URL=jdbc:postgresql://postgresqldb:5432/sonar -p 9000:9000 -d sonarqube
maven集成
在MAVEN_HOME/conf/settings.xml中,添加配置:
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.host.url>
http://localhost:9000
</sonar.host.url>
</properties>
</profile>
Java代码检测
mvn sonar:sonar命令执行代码分析