HUB
Sign inSign up

iotium/sonarqube

By iotium

•Updated about 11 years ago

SonarQube Container for Code Inspection with external Database container linking.

Image
0

1.9K

iotium/sonarqube repository overview

SonarQube Container for Code Inspection with external Database container linking.

⁠SonarDB

To use postgresql as DB for Sonar, Create Postgres Container

docker run --name pgsql -p 5432:5432 \
-e POSTGRES_PASSWORD=secret \
-e POSTGRES_DB=sonar -d postgres:latest

OR create database named sonar in the existing postgres DB server.

⁠SonarQube

To Link with Container

docker run -d \
-p 9009:9000 \
--link pgsql:pgsql \
-e SONAR_JDBC_USER=postgres \
-e SONAR_JDBC_PASSWORD=secret \
-e SONAR_JDBC_URL=jdbc:postgresql://pgsql:5432/sonar \
--name sonar -i iotium/sonarqube:latest

To Use existing DB

docker run -d \
-p 9009:9000 \
-e SONAR_JDBC_USER=postgres \
-e SONAR_JDBC_PASSWORD=secret \
-e SONAR_JDBC_URL=jdbc:postgresql://hostname:5432/sonar \
--name sonar -i iotium/sonarqube:latest
⁠Sonar Maven Profile

Then in your maven settings.xml file add the below content under <profiles>tag. That file will be in ~/.m2/settings.xml or /etc/maven/settings.xml

<profile>
  <id>sonarpgsql</id>
  <activation>
    <activeByDefault>false</activeByDefault>
  </activation>
  <properties>
    <sonar.jdbc.url>
      jdbc:postgresql://localhost:5432/sonar
    </sonar.jdbc.url>
    <sonar.jdbc.driverClassName>org.postgresql.Driver</sonar.jdbc.driverClassName>
    <sonar.jdbc.username>postgres</sonar.jdbc.username>
    <sonar.jdbc.password>secret</sonar.jdbc.password>
    <!-- optional URL to server. Default value is http://localhost:9000 -->
    <sonar.host.url>
      http://localhost:9009
    </sonar.host.url>
  </properties>
</profile>
⁠Sonar Plugin

Then add sonar-maven-plugin in your pom.xml

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>sonar-maven-plugin</artifactId>
  <version>2.6</version>
</plugin>

Refer more about that plugin http://mojo.codehaus.org/sonar-maven-plugin/plugin-info.html⁠

⁠To Run

To inspect your code run this below command where your pom.xml there

mvn sonar:sonar -Psonarpgsql

To See the sonar report http://localhost:9009/⁠

Tag summary

Content type

Image

Digest

sha256:6a4c309b8…

Size

333.4 MB

Last updated

about 11 years ago

docker pull iotium/sonarqube