sonarqube-community-branch-plugin
sonarqube-community-branch-plugin copied to clipboard
"View in SonarQube" link is prefixed with repo/project-path
Describe the bug Gitlab MR decoration link to "View in SonarQube" is prefixed with a Gitlab project link. I am using self-hosted Gitlab.
To Reproduce Steps to reproduce the behavior:
- Complete an analysis on the MergeRequest
- Navigate to the MergeRequest decoration in Gitlab
- Click the "View in SonarQube" link; page navigates back to the project/repo top page, with an error message on top of the page
Expected behavior When selecting the View in Sonarqube link, I expect to be redirected to Sonarqube
Screenshots
Example of what the View in SonarQube link is presenting. In the red box, you will see the correct URL! I am not sure why it is prefixed with a Gitlab URL.
The above link directs back to the project/repo top page, with this error:
Software Versions
- SonarQube Version: 8.9.7.52159
- Plugin Version: 1.8.1
- Gitlab: 14.10.5
Other info The link in "sonar.core.serverBaseURL" appears as I would expect: "https://sonar.domain.io"
I have not ruled out this being a Gitlab issue, but was hoping yall could provide feedback. I am not sure when the issue started, but it could have been anytime in the last 4 months after I upgraded to SonarQube 8.9.
Can you try removing and re-applying the sonar.core.serverBaseURL? I can't replicate your issue, but suspect there's something that's causing the protocol to be dropped by the Sonarqube when reading the properties.
I did some additional testing on a preprod environment where I am getting the same error.
I removed sonar.core.serverBaseURL, restarted sonarqube, added back sonar.core.serverBaseURL, and restarted again. But I am still seeing the same error.
From looking at the logs, I believe you are correct. The logs indicated that the https is being stripped when stating the error ( line 564 and 581): Only allowed schemes are http, https
Also, earlier in the log (line 489) I see the following, which indicates the URL is losing the scheme too:
\n[View in SonarQube](preprod1.sonar.mydomain.io/dashboard?id=devxtools_lab_sonar-scanning-examples_AX77AsE6sPPdfMMMsWAN\u0026pullRequest=22)
However, I am not sure at which point the scheme is being stripped off. Help appreciated.
For completeness, my URL is saved in the following format, which I believe is correct:
This "user error" is resolved.
The sonar.properties file was templated. When the box was originally deployed, it was missing the https schema. However, I suspect it may have been fixed via the Sonarqube Admin console. When we later began this investigation, we applied updates via the Sonarqube Admin web-console and restarted the sonarqube service, however, that was not addressing the issue.
The solution: we had to apply fix to the sonar.properties file. After this file change, restarting the sonarqube service alone still did not resolve the issue. We had to restart the entire container. After identifying this solution, we have also re-provisioned the box with the fix to the properties file, and it is still working, validating the root-cause.
TLDR, if you have a sonar.properties config, you may not be able to trust what is displayed in the Sonarqube admin web-console, as it appears to take presidence against what is in admin web-console.