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

updated getSonarProjectFromBuildReport to handle analysis URL that is… #131

Conversation

cburne-oshyn
Copy link
Contributor

… provided by sonarqube 9.3 which includes /dashboard?id=.." in the URL

Sonarqube Analysis url from Sonarqube 9.3 in the build log has the following structure:
INFO: ANALYSIS SUCCESSFUL, you can browse https://sonarqube.xxx.com/dashboard?id=XXX.Web

The current logic just appends the api call after the "/dashboard?id=XXX.Web". This new logic checks to see if there are three "/" chars in the url and if there are, it grabs the url prior to the 3rd "/". It should not touch the URL if there are only 2 slashes as in "https://sonarqube.xyz.com" (although I am unable to test this, I'm hoping @kumbasar can check this for me in his installation).

  • [x ] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • [x ] Ensure that the pull request title represents the desired changelog entry
  • [x ] Please describe what you did
  • [x ] Link to relevant issues in GitHub or Jira
  • [x ] Link to relevant pull requests, esp. upstream and downstream changes
    Re-add getting sonar project parameters from build log feature #129
  • [x ] Ensure you have provided tests - that demonstrates feature works or fixes the issue

… provided by sonarqube 9.3 which includes /dashboard?id=.." in the URL
@kumbasar
Copy link
Contributor

Hello @cburne-oshyn, sorry for my late response. I was a busy with other stuffs. So, for 8.9 LTS release, the build log also looks like as follows:

12:14:49  INFO: ANALYSIS SUCCESSFUL, you can browse https://prod.sonarqube.blahblah.net/dashboard?id=63e375e6-0b19-4b9e-87d0-218a629fda9c&branch=develop
12:14:49  INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
12:14:49  INFO: More about the report processing at https://prod.sonarqube.blahblah.net/api/ce/task?id=AX94Ql3Pr0yhtSb6a_cC
12:14:50  INFO: Analysis total time: 32.529 s

Which it's the same with yours. Right?

I am not getting this issue, because I have set the SONAR_HOST_URL in my environment which overwrites the parsed url
See:

String sonarServer = env.get("SONAR_HOST_URL", sonarBuildURL);

So, I believe that, below snippet should fix this issue:

url  = match.group(1);     // url =  "https://prod.sonarqube.blahblah.net/dashboard?id=63e375e6-0b19-4b9e-87d0-218a629fda9c&branch=develop"
url = url.substring(0,url.lastIndexOf(('/')));  // url = "https://prod.sonarqube.blahblah.net"

@@ -302,6 +302,10 @@ protected String getResult(String url) throws IOException {
match = p_analysis_url.matcher(line);
if (match.matches()) {
url = match.group(1);
long count = url.chars().filter(ch -> ch == '/').count();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below should be fine

url  = match.group(1);     // url =  "https://prod.sonarqube.blahblah.net/dashboard?id=63e375e6-0b19-4b9e-87d0-218a629fda9c&branch=develop"
url = url.substring(0,url.lastIndexOf(('/')));  // url = "https://prod.sonarqube.blahblah.net"

@asimell
Copy link
Contributor

asimell commented Feb 15, 2024

Hi @cburne-oshyn @kumbasar ,

I know this has been hanging for quite a while already. I'm currently increasing the overall unit test coverage for the whole plugin and I stumbled on this same bug and fixed it with d6bd919. I'll soon merge these unit tests/bug fixes into the main branch, so I will close this in favour of that PR. I did implement the fix based on this PR, so thanks for opening this 🙏

@asimell asimell closed this Feb 15, 2024
@cburne-oshyn
Copy link
Contributor Author

cburne-oshyn commented Feb 15, 2024 via email

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

Successfully merging this pull request may close these issues.

3 participants