Friday 20 July 2018

Moving SonarQube to other server

At first I had SonarQube installed together with Jenkins on the same server. SonarQube is quite resource demanding and it was causing slowness of the other jobs / tasks running on Jenkins.

Moving to other instance was simple as installing SonarQube on other server and configuring Jenkins to use new SonarQube instance.

Steps required

  • Java runtime environment
  • SonarQube binaries
  • MSSQL JDBC driver (make sure you get sqljdbc_auth.dll available on PATH)
  • SonarQube configuration was copied from old server to new (sonarqube/conf/*)
  • SonarQube instance was registered as service and started. 
  • Once the service is running then try to access it in browser, if it is not accessible then check logs (sonarqube/logs) and resolve.
  • Once the web is up and running there had to be installed language plugins again. 
  • Jenkins configuration have to be updated with new SonarQube url (Manage Jenkins > Configure System)

Thursday 3 May 2018

SonarQube AD authentication setup

User in SonarQube can be validated against ActiveDirectory, once the user is validated it will be automatically created which is useful if there are a lot users who are required to use the tool.

  1. LDAP plugin needs to be installed in SonarQube marketplace
  2. sonar.properties needs to be updated with LDAP configuration details
  3. SonarQube service needs to be restarted. 
  4. Go to SonarQube web. 
    • If there are issues with the configuration check the logs (SonarQube\logs\web.log)
# LDAP configuration
# General Configuration
sonar.security.realm=LDAP
sonar.authenticator.createUsers=true
ldap.url=ldap://ldapserver:389
ldap.bindDn=CN=username,CN=Users,DC=domain,DC=company,DC=com
ldap.bindPassword=password

# User Configuration
ldap.user.baseDn=DC=domain,DC=company,DC=com
ldap.user.request=(&(objectClass=user)(sAMAccountName={login}))
ldap.user.realNameAttribute=cn
ldap.user.emailAttribute=mail

ADExplorer is useful to confirm AD object properties and validate the server address and credentials.
In case it is not clear what are AD server details then use guidance on SO.
More details can be found in SonarQube LDAP plugin documentation.

Wednesday 2 May 2018

SonarQube MSSQL backend setup


  1. Create Database
    • CREATE DATABASE "sonar" COLLATE Latin1_General_CS_AS 
      • It needs to be case and accent sensitive
    • Create user and add permissions to user so tables can be created with SonarQube start
  2. Modify SonarQube configuration to point out to database created
    • Go to SonarQube\conf\sonar.properties and follow instructions in the file
      • Uncomment and change connection string e.g. sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar;integratedSecurity=true
      • In case there is not used integrated also specify sonar.jdbc.username and sonar.jdbc.password
  3. In case there is used integrated connection to database used then download Microsoft JDBC driver, unzip and somewhere to the system PATH place sqljdbc_auth.dll (either 32 or 64 bit based on your operating system)
  4. Restart SonarQube instance.