Sonar Scanner 7.0.1.4817 not picking up sonar.token from sonar-scanner.properties

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension) * Community Build v25.2.0.102705
  • how is SonarQube deployed: zip
  • what are you trying to achieve: Running sonar-scanner as part of Gitlab CI/CD pipeline to scan code. Upgraded sonar-scanner from 5.0.1.3006 to 7.0.1.4817 but sonar scanner is not picking up sonar.token from sonar-scanner.properties
  • what have you tried so far to achieve this
    verified that the sonar-scanner.properties has a valid sonar.token value.
    Also, added SONAR_TOKEN= inside sonar-scanner.properties
    Also, updated /opt/sonar-scanner/latest/bin/sonar-scanner to pass
exec "$java_cmd" \
  -Djava.awt.headless=true \
  -Djava.net.useSystemProxies=true \
  $SONAR_SCANNER_OPTS \
  $SONAR_SCANNER_DEBUG_OPTS \
  -DSONAR_TOKEN=<value>\
  -Dsonar.token=<value> \

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

sonar-scanner
12:07:15.843 INFO  Scanner configuration file: /opt/sonar-scanner/sonar-scanner-7.0.1.4817/conf/sonar-scanner.properties
12:07:15.848 INFO  Project root configuration file: /home/gitlab-runner/builds/<xxxx>/0/<xxxxx>/<xxxxx>/sonar-project.properties
12:07:15.871 INFO  SonarScanner CLI 7.0.1.4817
12:07:15.873 INFO  Java 21.0.6 Ubuntu (64-bit)
12:07:15.878 INFO  Linux 6.8.0-1021-aws aarch64
12:07:15.929 INFO  User cache: /home/gitlab-runner/builds/<xxxx>/0/<xxxxx>/<xxxxx>/.sonar/cache
12:07:17.333 INFO  EXECUTION FAILURE
12:07:17.334 INFO  Total time: 1.495s
12:07:17.333 ERROR Failed to query server version: . Please check the property sonar.token or the environment variable SONAR_TOKEN.

Hey there

I have the impression that you’ve maybe overcomplicated setting the token.

The only thing you should need to do is to set a SONAR_TOKEN variable in your repo under Settings > CI/CD > Variables.

Any other changes you’ve made to to the sonar-scanner executable or configured in the sonar-scanner.properties file should be undone.

I’d also suggest you target v7.0.2 of the scanner, as a bugfix release was done which affected token-based authentication (SCANJLIB-262, although it shouldn’t affect you, since you’re using a newer version of SonarQube).