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

**URL:** <https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793>\
**Category:** SonarQube Server / Community Build\
**Tags:** jenkins, github, scanner\
**Created:** [April 16, 2021, 11:44am UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793 "2021-04-16T11:44:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hanif\_nezhad](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/hanif_nezhad/32/21297_2.png) [@Hanif\_nezhad](https://community.sonarsource.com/u/Hanif_nezhad)\
**Post date:** [April 16, 2021, 11:44am UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793/1 "2021-04-16T11:44:43Z")

</div>

Hope you are in good health.

Must-share information (formatted with [Markdown](https://commonmark.org/help/)):

- which versions are you using (SonarQube Scanner 4.0.0.1744)
- 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-4.0.0.1744-linux/bin/sonar-scanner  
> INFO: Scanner configuration file: /opt/sonar\_scanner/sonar-scanner-4.0.0.1744-linux/conf/sonar-scanner.properties  
> INFO: Project root configuration file: /home/bitnami/jenkins/workspace/test-deployment/sonar-project.properties  
> INFO: SonarQube Scanner 4.0.0.1744  
> INFO: Java 11.0.9.1 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: EXECUTION FAILURE  
> 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:  
> 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

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [April 16, 2021, 12:38pm UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793/2 "2021-04-16T12:38:44Z")

</div>

Hey there.

> [@Hanif\_nezhad](#):
>
> 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:

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

---

<div class="post-metadata">

**Author:** ![Hanif\_nezhad](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/hanif_nezhad/32/21297_2.png) [@Hanif\_nezhad](https://community.sonarsource.com/u/Hanif_nezhad)\
**Post date:** [April 16, 2021, 12:41pm UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793/3 "2021-04-16T12:41:30Z")

</div>

Hi Colin,

its defined in the sonar-project.properties file in /home/bitnami/jenkins/workspace/test-deployment/sonar-project.properties

sonar-scanner   
-Dsonar.projectKey=develop   
-Dsonar.sources=.   
-Dsonar.host.url=http://53.78.163.22:9000   
-Dsonar.login=\<please\_redact\_your\_token\>

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [April 16, 2021, 12:44pm UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793/4 "2021-04-16T12:44:52Z")

</div>

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

```
sonar.projectKey=develop
sonar.sources=.
sonar.host.url=http://53.78.163.22:9000
sonar.login=<please_redact_your_token>
```

---

<div class="post-metadata">

**Author:** ![Hanif\_nezhad](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/hanif_nezhad/32/21297_2.png) [@Hanif\_nezhad](https://community.sonarsource.com/u/Hanif_nezhad)\
**Post date:** [April 16, 2021, 1:38pm UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793/5 "2021-04-16T13:38:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [April 19, 2021, 9:03am UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793/6 "2021-04-19T09:03:18Z")

</div>

You should make sure the `sonar-project.properties` 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`)

---

<div class="post-metadata">

**Author:** ![Hanif\_nezhad](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/hanif_nezhad/32/21297_2.png) [@Hanif\_nezhad](https://community.sonarsource.com/u/Hanif_nezhad)\
**Post date:** [April 20, 2021, 4:38pm UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793/7 "2021-04-20T16:38:33Z")

</div>

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 {
       script 
       {
           
            withSonarQubeEnv ('Jenkins-sonar-server'){
              sh "/opt/sonar_scanner/sonar-scanner-4.0.0.1744-linux/bin/sonar-scanner -Dsonar.projectKey=develop -Dsonar.sources=. "
            }
            }
        }

  }
```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [April 27, 2021, 4:39pm UTC](https://community.sonarsource.com/t/you-must-define-the-following-mandatory-properties-for-unknown-sonar-projectkey/41793/8 "2021-04-27T16:39:17Z")

</div>

Closed on April 27, 2021, 4:39pm UTC

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