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

feat: Pull Request support if using SonarQube community version with community-branch-plugin installed #55

Merged
merged 1 commit into from
Jan 12, 2024
Merged

feat: Pull Request support if using SonarQube community version with community-branch-plugin installed #55

merged 1 commit into from
Jan 12, 2024

Conversation

jsproede
Copy link
Contributor

@jsproede jsproede commented Dec 15, 2023

Hello again 😄

We have another Pull Request as we identified that this tool currently is unable to determine the correct issues and Quality Gate data when using SonarQube community version with the community-branch-plugin installed.

The issue is, that if the plugin is installed and enabled in SonarQube, the SonarQube API requires the Pull/Merge Request ID for which the issues and quality gate should be retrieved. The Pull/Merge Request ID can be specified by the query parameter &pullRequest=[ID].

Therefore we've added a new flag (--sonar-branch-plugin or -b), with which the community-branch-plugin support can be enabled in this tool. Then the pullRequest query parameter (we've added a TypeScript type for this matter) will be appended to each SonarQube API request and the Quality Gate Pull/Merge Request decoration comment URLs. We also needed to increase the INTERVAL_SECONDS variable to 5 minutes to be able to retrieve the newly created issues in SonarQube as there is some delay caused by our GitLab CI/CD jobs. 1 minute is not enough. Maybe we should make this configurable too?

I know this is a fairly large change. We've tested the changes with our self-hosted GitLab and SonarQube 10.3 with the community-branch-plugin installed in version 1.16.1 (I hope that official support of SonarQube 10.3 doesn't take too long 🤞). It'd be great if you could test our changes on your end, if you're interested in merging this pull request :)

@jsproede jsproede marked this pull request as draft December 18, 2023 07:15
@jsproede jsproede marked this pull request as ready for review December 18, 2023 07:19
@hblab-dieuhd
Copy link
Collaborator

hi @jsproede

can you show images of result for me?

src/sonar/request.ts Outdated Show resolved Hide resolved
@hblab-dieuhd hblab-dieuhd added the enhancement New feature or request label Dec 22, 2023
@jsproede
Copy link
Contributor Author

hi @jsproede

can you show images of result for me?

Hi @hblab-dieuhd, I'm not sure how to show screenshots of the result 😅 As soon as the Community-Branch Plugin is installed in SonarQube Community Edition, it is required to append the pullRequest Query Parameter to SonarQube's Search API to retrieve the correct issues from the PR analysis. Otherwise the SonarQube API returns issues from the main-branch. The PR decoration in GitLab/GitHub does not look different, the quality-gate-tool simply retrieves the correct issues, if SonarQube has the Community-Branch Plugin installed and the support of this plugin is enabled via --sonar-branch-plugin 😊 The first screenshot I've attached does contain the Pull Requests (Dropdown in SonarQube) for one of our projects. The second one shows the internal HTTP request from SonarQube itself if the plugin is installed where you can see, SonarQube appends automatically the PR number to the API request.

PRs in SonarQube Community Edition
Chrome HTTP request from SonarQube

@hblab-dieuhd hblab-dieuhd merged commit 567055e into dieuhd:master Jan 12, 2024
1 check passed
@dieuhd
Copy link
Owner

dieuhd commented Jan 12, 2024

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jsproede jsproede deleted the feat/sonarqube-branch-plugin-support branch February 6, 2024 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants