Installation process
To give a quick try at SonarQube, just follow the steps below.Get Started in Two Minutes
1. Download and unzip the SonarQube distribution (let's say in "C:\sonarqube" or "/opt/sonarqube")2. Start the SonarQube server:
# On Windows, execute:C:\sonarqube\bin\windows-x86-xx\StartSonar.bat# On other operating system, execute:/opt/sonarqube/bin/sonar.sh console
4. Download and unzip some project samples (let's say in "C:\sonar-examples" or "/opt/sonar-examples")
5. Analyze a project:
# On Windows:cd C:\sonar-examples\projects\languages\java\sonar-runner\java-sonar-runner-simpleC:\sonar-runner\bin\sonar-runner.bat# On other operating system:cd /opt/sonar-examples/projects/languages/java/sonar-runner/java-sonar-runner-simple/opt/sonar-runner/bin/sonar-runner
Install SonarQube server in Linux (Ubuntu/Debian)
Edit "/etc/apt/sources.list" and add:
# SonarQubedeb http://downloads.sourceforge.net/project/sonar-pkg/deb binary/
apt-get updateapt-get install sonar/etc/init.d/sonar start
Next, go to "Settings -> Update Center -> Plugin Updates" and update the Java plugin.
Restart the server with:
/etc/init.d/sonar restart
Install SonarQube server plug-ins
Setup the proxy in your local server
Edit "/opt/sonar/conf/sonar.properties" file and add:
#--------------------------------------------------------------------------------------------------# UPDATE CENTER# The Update Center requires an internet connection to request http://update.sonarsource.org# It is enabled bydefault.sonar.updatecenter.activate=true# HTTP proxy (defaultnone)http.proxyHost=proxy.my-proxy-url.comhttp.proxyPort=8080# proxy authentication. The2following properties are usedforHTTP and SOCKS proxies.http.proxyUser=my-proxy-userhttp.proxyPassword=my-proxy-pass
Save it and restart Sonar again.
Choose the plug-ins
- Go to "Settings" -> "Update Center" -> "Available Plugins"
- Install:
- Checkstyle
- PMD
- fb-contrib
- Restart Sonar server
Import production rules into local Sonar server
- Export production rules from
http://sonar.my-company.com/profiles - Choose "Sonar way with Findbugs" profile and back it up.
- Go to your local server
http://localhost:9000/profiles - Delete your local "Sonar way with Findbugs" profile
- Restore the previous profile using in this case the production profile file.
- Set this one as default
How to set up Active Directory validation with LDAP in SonarQube server
Open the file "/opt/sonar/conf/sonar.properties" and add below lines:
# LDAP Configurationsonar.security.realm=LDAPsonar.security.savePassword=truesonar.security.updateUserAttributes=truesonar.authenticator.downcase=truesonar.authenticator.createUsers=trueldap.authentication=simpleldap.url=ldap://my-ldap-host-serverldap.bindDn=cn=jiraldapquery,ou=Serviceaccounts,ou=X-ADM,dc=root,dc=localldap.bindPassword=HERE-THE-PASSWORD# User Configurationldap.user.baseDn=OU=standarduser,OU=X-RIS,DC=root,DC=localldap.user.request=(&(objectClass=user)(sAMAccountName={login}))ldap.user.realNameAttribute=cnldap.user.emailAttribute=mail# Group Configurationldap.group.baseDn=OU=groups,OU=X-RIS,DC=root,DC=localldap.group.request=(&(objectClass=group)(member={distinguishedName}))
More info here http://docs.codehaus.org/display/SONAR/LDAP+Plugin
Run a local analize with Gradle
Install Gradle
In Ubuntu Linux the process is quite easy:
sudo apt-get install gradle
To get the last Gradle version you need to add the below lines into your "/etc/apt/sources.list" (only for Debian distributions) and import the pgp key that's used to sign the repository
source.list snippet
deb http://ppa.launchpad.net/cwchien/gradle/ubuntu YOUR_UBUNTU_VERSION_HERE maindeb-src http://ppa.launchpad.net/cwchien/gradle/ubuntu YOUR_UBUNTU_VERSION_HERE main
Import of the PGP-Key
apt-key adv --keyserver keyserver.ubuntu.com --recv-key D7CC6F019D06AF36
Start code analysis with SonarRunner
cd [PROJECT_BASE_DIR]/bin/customgradle sonarRunner
Install and setup IDEs support
Eclipse IDE plugin
Add the below link into your "Available Software Sites"http://dist.sonar-ide.codehaus.org/eclipse/
On your Eclipse you need to set some properties, for example for BayWa project:
- Window -> Preferences -> SonarQube -> Preview Analysis Properties and then click on "New"
Sonar BayWa properties
sonar.buildbreaker.skip =truesonar.sources = srcsonar.binaries = classes
- Add the Sonar server into "Servers" section with below values:
Server URL = http://localhost:9000User = adminPassword = admin
- For each project select from context menu: "SonarQube" -> "Change ProjectAssociation..", the connection should be detected automaticly, just use "Finish" and analyes should start.
IntelliJ IDE plugin
Set up SonarQube in IntelliJ (take care with this plugin, it doesn't support multiple modules in a project without Maven)Set up SonarQube with the Communitiy Edition plugin
No comments:
Post a Comment