Executing Sonar-scanner in jenkins

jenkins

(Osborne Odhiambo) #1

I am having trouble setting the following analysis properties in jenkins to execute sonar scanner. please advice

sonar.projectKey=project12345
sonar.projectName=project_test
sonar.projectVersion=1.0
sonar.sources=/var/lib/jenkins/workspace/$JOB_NAME ------?


(vicky) #2

Hi @Osborne,

If you are using sonarqube plugin in jenkins then you don’t need to give relative path of your workspace but you can pass sonar.sources=. and it will work or you can also change according to your requirement like src. For me it was working fine this way. I hope it helps.


(Osborne Odhiambo) #3

Thanks Vicky, i was able to get that configured but now i am receiving a new error
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.765s
INFO: Final Memory: 9M/245M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Not authorized. Please check the properties sonar.login and sonar.password.
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed?
WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed?
ERROR: SonarQube scanner exited with non-zero code: 1


(vicky) #4

@Osborne As it clearly mentions that you have to set the sonar username and password by
sonar.login=username
sonar.password=password

or

sonar.login=“TOKEN”

For more info you can refer https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner#AnalyzingwithSonarQubeScanner-Use this document and look into security section. Also this will help
https://docs.sonarqube.org/display/SONAR/Analysis+Parameters#AnalysisParameters-OptionalParameters
I hope it helps


(Nikita Gryzlov) #5

just put . or other relative path from the project root.

UPDATE:
oh, sorry, missed the first answer in topic :frowning: