-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
Decorating Pull Requests #27
Comments
I'd initially like to aim for parity with how SonarQube currently works for PR decoration, so report the high-level metrics that are provided as part of the I'd started some work on this previously but then ran-out-of-time to carry it forward. I'll try and get it tidied up and pushed to Github to start a conversation from. |
@mc1arke looking forward to see your current progress on this feature |
+1 |
+1, I’m also willing to Support if needed |
I have made an initial implementation that works with Bitbucket Server. The screenshot is taken from Sonarqubes official site and my implementation will mimic what I can see from their screenshot. I took the decision to create a separate plugin initially to not interfere with your plugin. I have no problem merging it in when it is stable enough. You can find my plugin at https://github.com/goober/sonarqube-pullrequest-decorator-plugin Note that it is a very ruff first iteration to verify that my ideas worked. |
I have done some work with the Github integration tonight. You can see a sneak peek at my demo project I will submit the underlying code as soon as I have cleaned it up a bit. I haven't been able to test it on a Github Enterprise installation since I do not have access to that. |
any update on that please ? |
I've pushed my proposed implementation of Pull Request decoration to the 'pr-decoration' branch and raised Pull Request #30 for initial comments. This implementation provides support for decorating Github Pull Requests and has been tested against github.com but not against a Github Enterprise distribution yet. I've taken an alternative approach to @goober in retrieving Issues, using an implementation of My code still requires a bit of work to provide unit tests, clean-up the code and formatting, and refactor the APIs to prevent duplicate null/optional checking and duplication of the retrieval of metrics against different Pull Reuqest providers, but I'm happy for people to test is and provide issues/feedback/comments against the code as it currently stands. |
@mc1arke amazing work! Although I know nothing about SonarQube API, I took a look at PR. From my point of view, it looks amazing and it looks like it should be easy to expand with decorating individual files/lines, as you said in your comment. In case you don't know much about Gitlab, I'd also like to add few things (which might affect your API design):
Also, I really don't know if this is a bad idea or not, but... What do you think about automatically resolving issue as false positive (?) if you resolve discussion in Gitlab / not sure what would be similar action in Github/etc. ? P.S. At work, we use Gitlab, so I can't test this on anything but pet example on GitHub, which you probably also tested... :) Thank you for adding support to this! 😊 [1] https://docs.gitlab.com/ee/ci/junit_test_reports.html |
@mfolnovic I've started working on an implementation for Gitlab in #34. Still very basic, but I'm open to hear any suggestions you have for it. |
Please help Scanner Context:
In PullRequestBuildStatusDecorator I use And get
Definition:
|
@goober I though PR decoration is only for Github enterprise edition. This is what their docs says at-least. Will the same steps for enterprise work for regular GitHub( github.com) ? |
Looks good if you use up to date source code repos. With the really old version of bitbucket server we are using then the only way to comment is how the https://github.com/AmadeusITGroup/sonar-stash adds a comment. In theory all the logic to post comments is harvestable so probably can end up easily adding support this way as a backup. |
@mc1arke thank You for creating this plugin, really amazing work. Do You plan to add PR decoration for Azure Devops? I would appreciate it a lot :). |
I would kindly request PR decoration for Azure DevOps as well :). Thank you for creating this plugin and being awesome! |
@wskwierawskiInfoprojekt @RobCoPKC I'm more than happy to look at adding Azure DevOps, but I probably need some initial direction from people like you around what I need to do for authentication and any calls to endpoints as I've never used Azure DevOps before. |
There needs to be an option to define a personal access token which is generated in Azure DevOps and needs to have the "Code (Read & Write)" permission: This token should then be used to make an API call (I would assume the one described here) to create a comment for each detected issue under the pull request. It looks like this: I'm sorry I can't be more specific since I don't own the Developer Edition nor can I access SonarCloud logs. |
@mc1arke any updates? |
@mahmoud-samy Is there any particular work you're looking for an update on? |
@mc1arke yes, PRs decoration. |
I got the following error when I try to analyze a project with the latest SNAPSHOT version (1.2.1). I have all configured right. It seems to be a bug?
|
Is the private key you've entered for Github authentication valid? Without some details about your configuration, it's going to be difficult to diagnose this. |
Okay, the private key was not valid... The error message could be more detailed about this. Another thing is, that it doesn't work. I don't got the decoration in my Pull Request without any error message. That's all logs from the plugin:
Project configuration: CMD:
My GitHub Application has following rights:
|
There was no error handling on the parsing of the key hence a For your latest issue, if you turn on debug logging for the Github decoration classes then it will show the request and responses for the Github service calls, which should indicate why you're not seeing any report on Gitlab. To do this, add the following into
At a minimum, please share the lines containing |
Okay, here are the log messages. Request:
Response:
|
Given |
I got it working now. The problem was, that I have the installed App in my organization configured to have access to all repositories. If I select only one specific, it works! This is my exception, when I have the app configured to have access to all repositories:
|
It seems that this don't work with GitHub Actions. When I run the sonar analyse from command line on my local machine, the decoration will be published to the Pull Request. With GitHub Actions pipeline, it doesn't. Here are some Logs: Without GitHub Actions:
With GitHub Actions:
Here is the public repository: https://github.com/avides/sonarqube-pr-decoration-test/pull/1 This build was triggered from Command Line: This build was triggered by GitHub Actions: |
Is there any plan to support bitbucket cloud pull request decoration? I would assume the API would be more or less the same - however bitbucket cloud does not support app password, but oauth authentication - based on what I saw there is an API operation to retrieve app password based on those parameters which can be used in bearer token as basic authentication later on. |
@goober @mc1arke We all need to pitch in and buy you guys some beers or something, amazing work.
|
Never mind. I just realized it was not in the latest release. Building from source works.
via scanner invocation? It doesn't appear to work for me. Manually setting these in the project settings will be tedious for hundreds of repos.
With the above code what i get in jenkins logs is:
Which is quite correct. I can't figure out where it comes up with this analysis ID. EDIT: point 2 was internal issue. Works fine now with sonarqube 8.1 and latest snapshot from sq81 branch |
Hi there, I'm working on a bitbucket cloud integration and was already testing the API authentication. It seems that we can use app passwords for the authentication. At least I was able to call the related endpoints successfully. However, using app password for this would require the integrator (i.e. you and me) to have an additional (mostly paid) user just for sonarqube (yes, you could use your own user but I personally wouldn't do that as it looks kinda weird, right?). That's why I'm unsure if we should continue using this approach or come up with something different. In the end at least I wouldn't mind that but if it can be done easier (OAuth) then I'd also be up for that. Sources: https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html Ideas? |
@mc1arke any idea about my problems above? |
@loefflefarn from the logs you gave, the plugin was finding a commit to comment on, but that commit wasn't visible whilst browsing your repository in the UI. From looking at the logs for the various Github actions you fired, I can see that they use a ref to checkout a specific Pull Request, however I couldn't tell from your logs and repository what that commit actually was. Given you'd had multiple attempts at running your actions with various commits in-between, I wasn't able to pinpoint exactly which action execution matched up to your Sonarqube log, so couldn't tell if you'd potentially forced pushed over a commit, or if Github had effectively removed the original ref at the point you pushed more commits. I'm going to close this current issue just now since it's moved from being an feature request (which has been delivered) to covering issues people have discovered whilst testing that feature. Could you see if you can re-create the issue without over-writing any relevant evidence (i.e. only fire the action once) and raise it in a new issue please? |
Delivered in 1.3.0 |
I would like to start a discussion for how the plugin would be able to support pull request decorations in a similar way that the commercial plugin does.
A former discussion was made in #3, but the initial issue was not related to supporting pull request decorations so I open a new issue to track the discussion of supporting pull request decorations in one place. Please feel free to close this if it is more preferable to continue the discussion in the other issue.
This is a suggestion for a solution based on my initial investigation on how the plugin lifecycle works in sonarqube.
By hooking in as a ComputeEngine extension with a
PostProjectAnalysisTask
, where we have access to the necessary metadata like quality gate results, we have the possibility to decorate the pull requests with some metadata.For Bitbucket Server we would then use the Code Insights API.
However, the
PostProjectAnalysisTask
does not expose the individual issues reported in the scan so I suggest that we do this in two steps.Step 1 - Support pull request decoration with the data available within the
PostProjectAnalysisTask
Step 2 - Support pull request decoration of individual issues per line.
For step 2 I have not found any internal sdk to use to obtain the issues reported in the scan. Other plugins like quboo-sonarqube-plugin leverages sonarqubes REST api to obtain the necessary data about the scan.
See QubooConnector.java
If it is decided to go with the REST api approach we could still use the
PostProjectAnalysisTask
to decorate the changed lines within the pull request.@mc1arke I guess that you have a lot of thoughts on how you want to tackle this?
The text was updated successfully, but these errors were encountered: