SonarQube Administration

The ods-core repository contains a build recipe for a central SonarQube instance to which all Jenkins instances send reports to. The remainder of this document describes how that setup is done.

Modifying configurations, plugins, etc.

There is an admin user which is allowed to change settings, install plugins, etc. The password is located in the OpenShift project cd, inside the sonarqube-app secret.

Updating SonarQube to a new version

The SonarQube deployment is using an image built in the central ODS namespace. This image is based on the https://hub.docker.com/_/sonarqube, as can be seen in the ODS Dockerfile. If the previous version was installed using Tailor, follow the process to migrate from tailor to helm in https://www.opendevstack.org/ods-documentation/opendevstack/5.x/administration/helm-migration.html If the previous version was configured to use Atlassian Crowd as Authentication provider, run the script https://github.com/opendevstack/ods-core/tree/master/scripts/migrate-sonar-users.sh in order to migrate current users to use Saml as Authentication provider.

To update SonarQube, the following steps need to be taken:

  1. Configure new version

  2. Update BuildConfig

  3. Create new image

  4. Rollout new deployment

The following will guide you through this process.

To configure a new version of SonarQube, you need to update the configuration of ODS, which is located in the ods-configuration repository of your ODS project in Bitbucket. You need to have the latest master of this repository, as well as the ods-core repository in your current ODS version available locally. If you don’t want to do this manually, you can make use the repos.sh script:

UMBRELLA_DIR=~/opendevstack
BITBUCKET_HOST=bitbucket.acme.org
BITBUCKET_PROJECT=opendevstack
GIT_REF=v3.0.0
mkdir -p $UMBRELLA_DIR && cd $UMBRELLA_DIR
curl -LO https://raw.githubusercontent.com/opendevstack/ods-core/$GIT_REF/scripts/repos.sh
chmod +x repos.sh
./repos.sh --git-ref $GIT_REF --repos="ods-core,ods-configuration" --source-project https://$BITBUCKET_HOST/scm/$BITBUCKET_PROJECT

The script can also be used in an umbrella directory in which the repositories already exist. Once the repositories are at the desired revision, change SONAR_VERSION in ods-configuration/ods-core.env to your desired version. Commit the change and push it to Bitbucket.

Next, you should ensure that the SonarQube BuildConfig resource in the central ODS namespace is up-to-date, then trigger a new build so that a new image gets built. Finally, a new deployment should be rolled out which uses the newly built image. All of this can be done from the ods-core repository:

make install-sonarqube

This target depends on the targets apply-sonarqube-chart, start-sonarqube-build and configure-sonarqube which execute the steps described above (and can of course also be executed individually).