Once this is added I start getting build steps occurring in C:\Users\Sonarqube which confuses me. There is on reason for the build to be impacted, the SonarQube stages have not even been executed when this occurs. Also, I do not know why it would be using C:\Users\Sonarqube, this user has absolutely no relation to the pipeline which runs as the Jenkins user.
After adding Debug to the Sonar-Scanner executable I can see that it too is using the C:\Users\Sonarqube directory
12:32:56.407 INFO SonarScanner CLI 6.2.1.4610
12:32:56.411 INFO Java 17.0.12 Eclipse Adoptium (64-bit)
12:32:56.413 INFO Windows 10 10.0 amd64
12:32:56.429 DEBUG Scanner max available memory: 7 GB
12:32:56.465 DEBUG Create: C:\Users\sonarqube\.sonar\cache
12:32:56.466 INFO User cache: C:\Users\sonarqube\.sonar\cache
12:32:56.467 DEBUG Create: C:\Users\sonarqube\.sonar\cache\_tmp
The first thing I want to fix is not using C:\Users\Sonarqube for anything, how do I specify the directory used for Sonar-Scanner on a Windows host?
I’m rather surprised to see %scannerHome% rather than ${scannerHome} which has been in all the tutorial examples for quite some time. Where are you getting your example from?
I’m also surprised to not see a line like this in your piepline:
To define where the sonar-scanner should be found (matching a tool installation as documented here). Maybe the job is instead picking up a SonarScanner installation you already have under the SonarQube user?
Thanks for the reply, I have made a lot more headway and gotten this working properly but the odd issue persists with it using the Sonarqube user directory.
I am able to scan, push results, and succeed in my waitgate but C:\Users\SonarQube is still referenced in the logs
I also can make this work without scannerHome, but still have the user issue. This makes me certain it is not defaulting to a scanner that was installed with the webserver
bat '''
"C:\\SonarQube\\Scanner\\sonar-scanner-6.2.1.4610-windows-x64\\bin\\sonar-scanner.bat" -Dsonar.projectKey=PROJ -Dsonar.sources=. -Dsonar.host.url=https://contoso.com -Dsonar.token=TOKEN
'''
I still don’t know why it would default to C:\Users\sonarqube though, unless the agent is running at that user.
I suppose it would be difficult to test in production, but on a test server, I’d want to know what happens if this user doesn’t exist or is named something else. As this user says in the Jenkins community:
Jenkins will start things under the user it is itself running when it runs on the controller. Or as the user the agent is running as. Jenkins does not perform user switching.