You must define the following mandatory properties for 'Unknown': sonar.projectKey

Hope you are in good health.

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Scanner
  • what are you trying to achieve: trying to run the scanner with Jenkins deployment

In most case that I see people have issues with having unknown sonar.project.key i see they have NONE in the project file but mine detects it but still throws the error:

[ Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: Jenkins-sonar-server
[Pipeline] {
[Pipeline] sh
+ /opt/sonar_scanner/sonar-scanner-
INFO: Scanner configuration file: /opt/sonar_scanner/sonar-scanner-
INFO: Project root configuration file: /home/bitnami/jenkins/workspace/test-deployment/
INFO: SonarQube Scanner
INFO: Java Debian (64-bit)
INFO: Linux 4.19.0-9-cloud-amd64 amd64
INFO: User cache: /home/bitnami/.sonar/cache
INFO: SonarQube server 8.3.1
INFO: Default locale: “en_US”, source code encoding: “UTF-8” (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=163ms
INFO: Server id: 86E1FA4D-AXim13wYREtv62J3eWMe
INFO: User cache: /home/bitnami/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=88ms
INFO: Load/download plugins (done) | time=341ms
INFO: Process project properties
INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 3.525s
INFO: Final Memory: 6M/27M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for ‘Unknown’: sonar.projectKey
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
[Pipeline] }
WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeed?
[Pipeline] // withSonarQubeEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
[Checks API] No suitable checks publisher found.
ERROR: script returned exit code 2
Finished: FAILURE

Hey there.

It’s not clear to me – where have you defined sonar.projectKey?

Hi Colin,

its defined in the file in /home/bitnami/jenkins/workspace/test-deployment/


You’ll want your file to look more like this:


Still the same error. From your experience is there any other issues could be causing this error?

You should make sure the file is in the exact folder you’re executing the sonar-scanner from. If you really get stuck, you can just pass parameters direcctly to the sonar-scanner command (sonar-scanner -Dsonar.projectKey=develop)

Thanks Colin, your tip helped me find the solution.

For other users, I was running the sonar scanner from a declarative pipeline, I added the projectKey and source directly to the sh agent in the pipeline script and it recognized my key.

   agent {label 'test_bitnami'}
   steps {
            withSonarQubeEnv ('Jenkins-sonar-server'){
              sh "/opt/sonar_scanner/sonar-scanner- -Dsonar.projectKey=develop -Dsonar.sources=. "


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.