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

[Gitlab] Generate codeclimate.json for Gitlab Code Quality MR Widget #296

Open
jkroepke opened this issue Jan 14, 2021 · 8 comments · May be fixed by #974
Open

[Gitlab] Generate codeclimate.json for Gitlab Code Quality MR Widget #296

jkroepke opened this issue Jan 14, 2021 · 8 comments · May be fixed by #974
Labels
enhancement New feature or request

Comments

@jkroepke
Copy link

jkroepke commented Jan 14, 2021

Gitlab released the Code Quality MR Widget to the core edition of gitlab.

https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html

It would be great to see this feature as part of the pull request decorator for gitlab.

Currently, the defunct plugin https://github.com/gabrie-allaigre/sonar-gitlab-plugin provide this feature but running this plugin could be a risk since no one maintain this plugin and no one could guarantee the compatibility betten this and sonar-gitlab-plugin plugin.

Take a look at the implementation details: https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#implementing-a-custom-tool

@jkroepke jkroepke changed the title [Gitlab] Generate codeclimate.json for Code Quality [Gitlab] Generate codeclimate.json for Gitlab Code Quality MR Widget Jan 14, 2021
@mc1arke mc1arke added the enhancement New feature or request label Jan 23, 2021
@123Haynes
Copy link

123Haynes commented Jan 30, 2021

Note that this fork of the project works just fine with the current sonarqube version (8.6.x).
https://github.com/javamachr/sonar-gitlab-plugin

So I suggest looking at the fork for inspiration instead of the defunct version.

@lucasoares
Copy link

Note that this fork of the project works just fine with the current sonarqube version (8.6.x).
https://github.com/javamachr/sonar-gitlab-plugin

So I suggest looking at the fork for inspiration instead of the defunct version.

I'm currently using the sonar-gitlab-plugin. The issue here is because we can't use pullrequest feature of sonarqube-community-branch-plugin to generate codeclimate report:
image

Apparently, if I do not specify a branch name if I'm using both plugins, the sonar-gitlab-plugin generates an empty report.

It would be awesome if this branch plugin could generate the report file!

@adpeyre
Copy link

adpeyre commented Feb 23, 2021

I agree with you @lucasoares !

@jkroepke
Copy link
Author

jkroepke commented Feb 26, 2021

Cross-Reference for empty reports on pull requests

javamachr/sonar-gitlab-plugin#9

I have this problem on a developer edition instance, too.

@lucasoares
Copy link

Hello guys.. Any news here?

@ezintz
Copy link

ezintz commented May 14, 2022

I am not quite sure, but would it make sense to "merge" efforts instead of "duplication" of the logic? I think that would result in a great benefit for the community. 🤓

@lucasoares
Copy link

Agreed @ezintz

Unfortunately I do not have time right now to bring code climate generation from the other plugin to this one but it would be great!

@kakawait
Copy link

kakawait commented Oct 4, 2024

The plugin sonar-gitlab-plugin is relying on /api/issues/search with query-parameter pullRequest to retrieve information and generate json.

Unfortunately the pullRequest parameter isn't available for CE edition.

Thus I've copied the same logic here

kakawait@ca8ca9c

By creating a new endpoint called /api/project_pull_requests/gitlab_report with 2 mands parameters

  1. project
  2. pullRequest

This endpoint will transform all OPEN issue to GitLab codeclimate json format.

Thus simply add following inside your .gitlab-ci.yml after the analysis to get report (adapt your variables name, only CI_MERGE_REQUEST_IID is predefined)

    - |
      curl -o gl-code-quality-report.json --header "Authorization: Bearer ${SONAR_TOKEN}" "${SONAR_HOST_URL}/api/project_pull_requests/gitlab_report?project=${SONAR_PROJECT_KEY}&pullRequest=${CI_MERGE_REQUEST_IID}"
  artifacts:
    reports:
      codequality: gl-code-quality-report.json

And tada is working

If approach is quite ok for the mainstream project, I could cleanup and propose PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
7 participants