SonarQube does not pick up sonar.properties

When I build an image in Docker (docker build . -t sonar) and run the container (docker run -d --name sonar -p 8080:9000 sonar) , the properties inside sonar.properties are not picket up by the installation of sonarqube.

for testing purposes I wiped the sonar.properties to only put 1 line (the first in the admin - system screen) in that properties file to see if it gets picked up. Can anyone tell what is going on?

=========================================
Dockerfile:

FROM openjdk:8-alpine
# Specify plugin versions
ENV JAVA_PLUGIN_VERSION             5.4.0.14284
ENV WEB_PLUGIN_VERSION              2.6.0.1053
ENV JS_PLUGIN_VERSION               4.1.0.6085
ENV GIT_PLUGIN_VERSION              1.4.1.1128

ENV GITLAB_PLUGIN_VERSION           3.0.1
ENV GITLAB_AUTH_PLUGIN_VERSION      1.3.2

ENV PMD_PLUGIN_VERSION              2.5
ENV CHECKSTYLE_PLUGIN_VERSION       4.10.1

RUN apk add --update-cache \
        bash \
        curl && \
        rm -rf /var/cache/apk/*

ENV SONAR_VERSION=7.1 \
    SONARQUBE_HOME=/opt/sonarqube
    # Database configuration
    # Defaults to using H2
# Http port
EXPOSE 9000

RUN addgroup -S sonarqube && adduser -S -G sonarqube sonarqube

RUN set -x \
    && apk add --no-cache gnupg unzip \
    && apk add --no-cache libressl wget \
    && apk add --no-cache su-exec \
    && apk add --no-cache bash \
    # pub   2048R/D26468DE 2015-05-25
    #       Key fingerprint = F118 2E81 C792 9289 21DB  CAB4 CFCA 4A29 D264 68DE
    # uid                  sonarsource_deployer (Sonarsource Deployer) <infra@sonarsource.com>
    # sub   2048R/06855C1D 2015-05-25
    && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE \
    && mkdir /opt \
    && cd /opt \
    && wget -O sonarqube.zip --no-verbose https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip \
    && wget -O sonarqube.zip.asc --no-verbose https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip.asc \
    && gpg --batch --verify sonarqube.zip.asc sonarqube.zip \
    && unzip sonarqube.zip \
    && mv sonarqube-$SONAR_VERSION sonarqube \
    && chown -R sonarqube:sonarqube sonarqube \
    && rm sonarqube.zip* \
    && rm -rf $SONARQUBE_HOME/bin/*

VOLUME "$SONARQUBE_HOME/data"

WORKDIR $SONARQUBE_HOME
COPY run.sh $SONARQUBE_HOME/bin/

COPY sonar.properties $SONARQUBE_HOME/conf/
ENTRYPOINT ["./bin/run.sh"]

==========================
run.sh

#!/bin/sh

set -e

if [ "${1:0:1}" != '-' ]; then
  exec "$@"
fi

chown -R sonarqube:sonarqube $SONARQUBE_HOME
exec su-exec sonarqube \
  java -jar lib/sonar-application-$SONAR_VERSION.jar \
  -Dsonar.log.console=true \
  -Dsonar.web.javaAdditionalOpts="$SONARQUBE_WEB_JVM_OPTS -Djava.security.egd=file:/dev/./urandom" \
"$@"

=================================================
sonar.properties
sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnap=2

Hi,

What’s your evidence for “not picked up”? If it’s that your sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnap setting wasn’t honored, well… that’s because that property can’t be set via sonar.properties, which is why you didn’t find it there originally.

The first time you set these things via the UI (or web servcies!) they’ll be persisted to the database, so this isn’t something you should need to re-configure at each startup anyway.

Ann

In the page ‘General Settings’, the first option ‘Keep only one analysis a day after’ has the Key: sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay , so I was under the assumption that all ‘keys’ could be used in the sonar.properties - file.

if that property cannot be set in the properties-file, why does it have a reference to a key?

thanx for your time / reactions btw! much appreciated!

Hi,

Many of the analysis-related settings can be set on the analysis side, which is why keys are shown at all. However, server-related settings that show up in the UI can only be set through the UI. And the inverse is true as well, the settings you’ll find in sonar.properties can only be set in that file.

So why are the keys of those UI-set values displayed? … Good question. Let’s say it’s a default behavior that never got revisited.

Ann

oh. if I write a plugin for sonarqube, would it be possible to use the sonar.properties file to add plugin related settings? my sonarqube is provisioned to different environments by our CI/CD pipeline, so I am not to try to set up the settings by hand in all environments :wink:

Hi,

I honestly have no idea.

Ann