SonarQube PL/SQL (.sql) file analysis

sonar.projectKey=mysqltestkey
sonar.projectName=mysqltest
sonar.projectVersion=1.0
sonar.projectDescription=PL/SQL demo
sonar.sources=C:/Users/Ganesh/Desktop/sqlscripts
sonar.language=plsql
sonar.sourceEncoding=UTF-8

I tried analysing using the above script but I am getting the below error.

ERROR: You must define the following mandatory properties for ‘Unknown’: sonar.projectKey

Hello,

The bit you shared does not look like script - it is rather just a bunch of properties and values assigned to them. It is also not clear how the scanner is executed here. You may want to save those to sonar-project.properties in the project root directory (as explained at https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/) and re-exeucte the scan.

Hope that helps.
Kris

Hi Kris,

sorry for typo,It is not a script, it is a property file contents.I already followed the steps mentioned in the document and installed the sonar scanner in the below path C:\Users\Ganesh\Downloads\sonarqube-8.2.0.32929\scanner\sonar-scanner-4.2.0.1873-windows and I saved the property file and script files (.sql) in the below path C:\Users\Ganesh\Downloads\sonarqube-8.2.0.32929\scanner\sonar-scanner-4.2.0.1873-windows\bin
I navigated to the root directory (C:\Users\Ganesh\Downloads\sonarqube-8.2.0.32929\scanner\sonar-scanner-4.2.0.1873-windows\bin>) and ran the sonar-scanner.bat file but I am getting the error message as “You must define the following mandatory properties for ‘Unknown’: sonar.projectKey”

Hello Ganesh,

it seems like you try to run the scanner using the absolute path while being in the scanner directory:


Add the sonar-scanner.bat location to you PATH environment variable, cd to the directory of the project (where the sonar-project.properties reside) and run the analysis from there.
Let me know how did that go.
Kris

Hi Kris,

I added the sonar-scanner.bat location to my PATH environment variable, cd to the directory and ran the analysis from there,I am still getting the same error message.

Can any one please help on this?

please update.

Hi @Ganesh_M,
As @Krzysztof_Jazgara explained:

  1. Put all properties from your initial comment into a file named “sonar-project.properties”
  2. Store the file in your project folder C:/Users/Ganesh/Desktop/sqlscripts/sonar-project.properties
  3. Navigate into the project folder “cd C:/Users/Ganesh/Desktop/sqlscripts”
  4. Invoke the SonarQube scanner “sonar-scanner.bat”
1 Like