Search This Blog

Friday, May 8, 2015

Sonarqube Setup and Upgrade

Setup and Upgrade

To give a quick try at SonarQube, just follow the tutorial below.
To install a production instance, follow the installation guide.
To upgrade your SonarQube instance, read the upgrade guide and the related upgrade notes.

Get Started in Two Minutes

1. Download and unzip the SonarQube distribution (let's say in "C:\sonarqube" or "/etc/sonarqube")

2. Start the SonarQube server:
# On Windows, execute:
C:\sonarqube\bin\windows-x86-xx\StartSonar.bat
 # On other operating system, execute:
/etc/sonarqube/bin/[OS]/sonar.sh console
3. Download and unzip the SonarQube Runner (let's say in "C:\sonar-runner" or "/etc/sonar-runner")

4. Download and unzip some project samples (let's say in "C:\sonar-examples" or "/etc/sonar-examples")

5. Analyze a project:
# On Windows:
cd C:\sonar-examples\projects\languages\java\sonar-runner\java-sonar-runner-simple
C:\sonar-runner\bin\sonar-runner.bat
# On other operating system:
cd /etc/sonar-examples/projects/languages/java/sonar-runner/java-sonar-runner-simple
/etc/sonar-runner/bin/sonar-runner
6. Browse the results at http://localhost:9000 (default System administrator credentials are admin/admin)

7. open x:\apache-maven-3.2.3\conf\settings.xml, paste under  (optional)

 <settings>
    <pluginGroups>
        <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
    </pluginGroups>
    <profiles>
        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- Optional URL to server. Default value is http://localhost:9000 -->
                <sonar.host.url>
                  http://myserver:9000
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>
</settings>

           
       



8. in your project root pom.xml,
 8.1  paste under 
 UTF-8
java



8.2paste under
               

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

               

OR

       <build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
</plugin>
</plugins>
</pluginManagement>
</build>

9. Go to cmd, your project root folder and type 

mvn clean install
mvn sonar:sonar

10. goto http://localhost:9000  [under projects you can see the reports]

11. If you want Html report
mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.issuesReport.html.enable=true
under your /target/sonar/issues-report folder you can see the html
http://docs.sonarqube.org/display/SONAR/Setup+and+Upgrade

No comments:

Hit Counter


View My Stats