Error in SonarCloudPrepare in Azure DevOps when no SONAR_SCANNER_OPTS set in version 1.8.0 and ScannerMode is CLI

Template for a good bug report, formatted with Markdown:

  • versions used:

SonarScanner for Azure DevOps 1.8.0

  • error observed:

##[error]Cannot read property ‘concat’ of undefined

  • steps to reproduce:

SonarCloudPrepare with ScannerMode set to CLI and no SONAR_SCANNER_OPTS set

  • potential workaround

set SONAR_SCANNER_OPTS should make it work

Looking at the code, it seems like if the scanner mode is set to CLI, the scanner will try to get the SONAR_SCANNER_OPTS and concat them with other variables, something that will fail when there are no SONAR_SCANNER_OPTS set.

Is there a reason why its done like that? Or is it just a bug?




Thanks for the report. We released new versions of the SonarQube/SonarCloud Extension for Azure Devops about an hour ago, which evidently contains this nasty bug. Since extensions auto-update… well, at least the feedback loop is pretty short. :slight_smile: Scanning with the CLI should not fail if SONAR_SCANNER_OPTS isn’t provided.

We can reproduce this on our side and a fix is on the way.



Same issue here. Good to know you are already on the case!

Experiencing the same issue with SonarQube. Hope this is resolved soon.

For the workaround, is there a suitable benign value I can set for SONAR_SCANNER_OPTS, does anybody know?

For the workaround, is there a suitable benign value I can set for SONAR_SCANNER_OPTS, does anybody know?

Would also be interested in this.

We fixed this problem by setting the SONAR_SCANNER_OPTS to empty in our azure pipeline as seen here:

1 Like

This works but the pipeline then fails on our side on Run Code Analysis with error Could not find or load main class Api

what’s the equivalent to SONAR_SCANNNER_OPTS using yaml ?

I tried sonar.web.javaOpts="" under extraProperties but that didn’t work

SONAR_SCANNER_OPTS is an environment variable, so take a peek at the documentation for Variables in Azure Devops Pipelines.

I just fixed two builds, first build empty value helped but second build (pretty big Angular) value was SONAR_SCANNER_OPTS=-Xmx2048m

yikes, so in expects an environment variable by that name!!


New version of this extension is available, fixing this bug (4.7.1)

Please note that if you intend to add values in the SONAR_SCANNER_OPTS environment variables, please provide them before the prepare analysis task, so that they will be correctly passed to the scanner.

Sorry for the inconvenience.



Likewise, although I’m getting a different error - not sure if the expected variable differs from my config now.

ERROR: You must define the following mandatory properties for ‘Unknown’: sonar.projectKey
ERROR: Error during SonarQube Scanner execution


Which kind of configuration for standalone scanner are you using ? With a file, or with manual configuration ?



Could you please provide the log of the Run Code Analysis task with debug activated please ?

Just the beginning should be enough, and redacted if needed.


how to activate debug?

Hey all,

I am able to reproduce the Could not find or load main class error by using a project name with a space included. The workaround… changing the project name to not have a space included.

This issue persists in the fix version released this afternoon. I’ve reported this internally.


A ticket has been created to track and troubleshoot this issue :