Install SonarQube on Mac and challenge source analysis

SonarQube installation procedure

--Easy installation with brew

$ brew install sonarqube

--Maven is also installed with brew. So Java is the source for this analysis

$ brew install maven

--Postgre was already installed on my device, so create an account and skimmer --Account name: sonar --Password: sonar --Schema: sonar

--SonarQube settings

#
# sonar.properties location
#
$ pwd
/usr/local/Cellar/sonarqube/7.3/libexec/conf

#
# sonar.Properties settings
#
$ cat sonar.properties | grep -v "^#" | grep -v "^$"
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonar
sonar.web.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError
sonar.web.host=127.0.0.1
sonar.web.context=/sonar
sonar.web.port=9000
sonar.path.data=/usr/local/Cellar/sonarqube/7.3/libexec/data
sonar.path.temp=/usr/local/Cellar/sonarqube/7.3/libexec/temp

--Launch SonarQube

$ sonar start

--Access SonarQube with your browser

http://localhost:9000/sonar

Previously, the setup didn't work and I was throwing it out, so this time I was upgrading from 7.2 to 7.3. Then, a message was displayed on the browser saying that the contents of the DB are also old and that you should upgrade. Again, I was in trouble because I didn't know how to do it, but when I looked at the log, a hint was output to the log. As supported, when I accessed / setup, the top page was displayed successfully ♪

$ pwd
/usr/local/Cellar/sonarqube/7.3/libexec/logs

$ tail sonar.log
################################################################################
      Database must be upgraded. Please backup database and browse /setup
################################################################################

http://localhost:9000/sonar/setup

--Source analysis

#
#Move to the directory of the Eclipse project that has the source analysis target
#
cd "Project directory"

#
#Command execution for preparation
#
$ mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true

#
#Source analysis command
#
$ mvn sonar:sonar

An error occurred with the "mvn sonar: sonar" command. When I ran it in debug mode, it turned out that it failed because the path was different. (/ Sonar is not attached)

$ mvn sonar:sonar -X
ERROR: Sonar server 'http://localhost:9000' can not be reached

Add the following to maven setting.xml and re-execute the command, then BUILD SUCCESS !!!

<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://localhost:9000/sonar
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>
</settings>

--I was able to confirm the analysis result on the browser. By the way, the login ID and path was admin.

References

Recommended Posts

Install SonarQube on Mac and challenge source analysis
Install gradle on mac
Install java and android-sdk on Mac using homebrew
Install Java on Mac
Install openjdk11 on mac
Install OpenJDK 8 on mac
Install java and maven using brew on new mac
Install Eclipse on Mac and translate it into Japanese
Install tomcat + eclipse on mac
Install JDK and JRE on Ubuntu 16.10
Install and configure jenv on macOS
Install apache 2.4.46 from source on CentOS7
Install SonarQube on ECS instance on Ubuntu 16.04
Install Java 9 on windows 10 and CentOS 7
Challenge to install WSL2 and docker
Install Java development environment on Mac
Steps to install Maven on Mac and use it in Eclipse
Install Ubuntu Server 20.04 in VirtualBox on Mac and connect with SSH
Install docker and docker-compose on Alpine Linux
Install samba4 from source code on CentOS8
How to install Eclipse (Photon) on Mac
I can't install rails on my mac
Download and install Eclipse (Java) (Mac version)
Put Java 11 and spring tool suite on mac
Build and install Wireshark Development Release (3.3.1) on Ubuntu
Install Ruby / Rails on Mac M1 Big Sur 2021-01
Install and switch between multiple Javas on Ubuntu
Ssh to Ubuntu on VirtualBox on your Mac and do it until you install Docker
Install rbenv with apt on ubuntu and put ruby
I struggled with pip install on an M1 Mac
How to install Gradle and Kotlin with SDKMAN (Mac)
Install ag (the silver searcher) [on CentOS / Ubuntu / Mac]