Closed B3nedikt closed 3 years ago
Hello
The plugin doesn't use sonar-scanner.properties. Instead, it passes needed parameters through the CLI arguments. How do you start analysis?
When using the generic runner we start analysis by directly running the sonar-scanner CLI with all the needed parameters as command line arguments, except the username & the password, from a TeamCity Command Line Runner.
When using the gradle runner we just run the "sonarqube" gradle task from the TeamCity Gradle Build Runner, we set all parameters except the username & the password directly in the gradle build script.
Hmm. In this case, could you please explain how you do this:
Set SonarQube username & password in the TeamCity UI for the first time
The SonarQube Plugin provides a separate build runner (SonarQube Runner) which uses authentication from Server Connections. But the plugin isn't designed to be used with generic commandline runner nor with gradle.
So what I am trying to explain is that I don't quite understand how your setup works at the beginning.
Now that you are asking, I don't understand it either xD I just configured the username & password in this plugins UI and it worked, it makes no sense to me why it did now. I thought the plugin opens a Server Connection which also works for the gradle and the generic SonarQube Runner, not only for the separate build Runner provided by this plugin. For whatever strange reason this also seams to work for gradle, but not for the generic one ?
But anyway, I guess the way I am using this plugin is wrong, I guess I will need to switch to manually managing the global sonar-scanner.properties file.
However a UI for this in TeamCity would be cool to have, would you consider adding this feature? Or maybe just a way to ensure there is an open Server Connection during a Build.
Yes, such a feature could be useful in some cases. But there are also cases when people want to perform analysis on 2 different SonarQube servers in the same build. So having 2 different connections - which one should be enabled in the global file at which time? But anyway, we will keep this option in mind. Thank you for bringing this up.
That makes sense, I did not think of this use case. I will switch now to simply using a environment variable in the root project for the token, I think this is the simplest solution in my case. Thanks for looking into this :)
Steps to reproduce:
If I now start a analysis using the generic SonarScanner, it will fail as the old username & password from the global properties file are used, even though the TeamCity UI displays the correct new username. When using tokens the behaviour is the same. If I use the gradle SonarScanner and not the generic one the new username & password get picked up correctly though and everything works as expected. After manually updating the global properties file, the generic SonarScanner works again as well.
I am not sure if this behaviour is intentional, does this plugin actively manage the global properties file, or is this the responsibility of the user?