sonarCommand is the command line to send to Powershell.
If the command returns a nonzero status code, Jenkins returns an exception. It is dirty…
I’d like to know what is the return value when the Sonar scanner doesn’t see any difference, and so produces an empty JSON. I don’t succeed to find this value in the documentation.
Also, would it possible to not even try to run the scanner, by asking to SonarQube Cloud what was the commit used for the last analysis, and what was the analysis status ? What is the good practice ?
The one leading to this error message when it is empty
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
By “empty”, I mean with it points to no differences since lasts scan.
Yes… I was confused by your assertion that the problem was that the project hadn’t been modified since the last scan.
In fact, your log shows analysis ending successfully.
It also shows that this is a PR analysis, and PR analysis will always look at all the changes in the underlying branch, whether or not you’ve already analyzed them before.
Best practice is to have your pipeline notice that there has been a change and fire automatically based on that.
Why? Instead of invoking PoweShell to invoke the scanner… why not just invoke the scanner directly?
By using the Sonar API to ask the SHA1 for the last scan, and comparing it with the SHA1 we plan to scan ?
Well… Anyway, in Jenkins, we have to use the bat or the powershell commands. They’re same. We just have to add an ampersand with the powershell command.
But maybe I musunderstood what you mean.
I don’t understand. A notification of which event (my SCM is Git) ? When ?
When I want to launch the run #N of a job Jenkins, for a given Git SHA1, I need to know if a Snar scan has already be done for this SHA1. In my job Jenkins, I do know what is the SHA1 for the processed branch, but I don’t know the SHA1 used for the previous scan.