Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose SonarQube server URL as a build parameter #70

Open
ogerovich opened this issue Oct 15, 2019 · 4 comments
Open

Expose SonarQube server URL as a build parameter #70

ogerovich opened this issue Oct 15, 2019 · 4 comments

Comments

@ogerovich
Copy link

There is already %runParam.sonarServer%, but it's some kind of unique identifier. Please provide something like %runParam.sonarServerUrl%. This way I could pass it as a parameter within a build step to my custom script.

@Linfar
Copy link
Member

Linfar commented Oct 22, 2019

Yes, sonarServer is UUID of a connection used in a certain build step. When build is started a number of additional parameters are resolved basing on this UUID, including sonar.host.url with the URL. However due to current implementation these parameters are set only for starting build and cannot be accessed on server side.

Could you please describe how do you get access to runner parameters - where runParam prefix comes from?

@ogerovich
Copy link
Author

When I was testing my script earlier, I was using SonarQube plugin 2017.1-28. I used a Python build step. I started typing %sonar in command line arguments text box, and a few matches appeared. %runParam.sonarServer% was among them. When I tried to run the build, I discovered that it's the UUID. I have since updated SonarQube plugin to version 2017.1-30, and auto-complete no longer shows any matches for %sonar. Was this disabled between 2017.1-28 and 2017.1-30?

It does not matter to me how the parameter is exposed as long as I can use it either in a build step or to define another build parameter. Ideally, auto-complete works, but this is not a requirement.

@Linfar
Copy link
Member

Linfar commented Oct 23, 2019

%runParam.sonarServer% isn't a parameter provided by SonarQube plugin (and has never been). AFAIK default TeamCity functionality doesn't provide runParam. prefix neither. Moreover runner parameters can exist only during executing step where these parameters are defined and mean nothing in other steps.

So I cannot easily provide such parameter from the plugin - eg there can be 2 different Sonar Runner usages with different servers during one build.

MSBuild Scanner seems to be easier here since usually there is only one simultaneous Start task (there can be subsequent 2 start-finish tasks during the build but I really doubt anyone will ever intersect them) and server is used in the Start task. So probably I can set parameter value between start and finish.

I'll try to find some way to provide SonarQube server urls. If you can describe how you'll use such parameter it could help me.

@ogerovich
Copy link
Author

I'm now unsure about how I discovered runParam. I thought it was auto-complete, but, if it was never provided, maybe I just looked at a completed build and found it on Parameters tab.

I need the URL for SonarQube Runner and SonarScanner for MSBuild. After those build steps, I have a command-line step that calls a script, which accepts %PARAMS% build parameter. PARAMS is defined on Parameters tab as a string, which contains the hard-coded Sonar URL like this ... /set SERVER_URL=http://myserver:900 .... I'd like to have some reference, ideally with auto-complete, so I could do something like this: ... /set SERVER_URL=%SONAR_URL% ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants