gabrie-allaigre / sonar-gitlab-plugin

Add to each commit GitLab in a global commentary on the new anomalies added by this commit and add comment lines of modified files
GNU Lesser General Public License v3.0
713 stars 207 forks source link

How to use this plug-in to generate and display sonarqube reports in Gitlab when using Jenkins? #189

Open rajeshhereforyou opened 5 years ago

rajeshhereforyou commented 5 years ago

Hi,

Here is what I'm trying to achieve.

Whenever there is merge request created or change in a branch in GitLab, sonarqube should run the static code analysis and send that report back to Gitlab and display it there so that MR approver can see the report and take decision based on it.

victorescalante commented 5 years ago

Hi, I find the same situation, have you found any solution?

Veranicus commented 5 years ago

Hi there, I have been dealing with this issue some time ago.

There is one potential way how to solve this, check this thread: https://stackoverflow.com/questions/48907308/why-is-sonar-gitlab-plugin-not-sending-analyze-results-to-gitlab-as-a-comments-w?noredirect=1#comment85885601_48907308

I'm not however sure whether it works.

Another way how to solve this is having some of the Gitlab paid-for versions, to use Gitlab API called I think Gitlab pages. Or you can always use Gitlab runner instead of Jenkins.

Hope it helps and saves some time.

rverma-nikiai commented 5 years ago

@gabrie-allaigre Hi, facing similar issue with another gitlab external CI(drone-ci). The sonarscanner analysis runs successfully with sonar-project.properties as

sonar.sourceEncoding=UTF-8
sonar.language=java
sonar.java.binaries=target/classes,target/test-classes
sonar.gitlab.project_id=11315201
sonar.gitlab.commit_sha=bce400f5bb21c5c2b4a0f682e353309875aaf13e
sonar.gitlab.ref_name=feature/IT-19
sonar.branch.name=feature/IT-19

And corresponding results are published to sonarqube(Tried with both 7.6/7.7 community). Plugin version 4.0, 4.0.1-snapshot, 4.1.0-snapshot.

In sonar server able to see logs like

2019.03.21 04:21:01 INFO  ce[AWmeeuvpfejeH12FY31i][o.s.c.t.s.ComputationStepExecutor] Send issue notifications | newIssuesNotifs=0 | newIssuesDeliveries=0 | myNewIssuesNotifs=0 | myNewIssuesDeliveries=0 | changesNotifs=0 | changesDeliveries=0 | status=SUCCESS | time=3ms
2019.03.21 04:21:01 INFO  ce[AWmeeuvpfejeH12FY31i][o.s.c.t.s.ComputationStepExecutor] Publish task results | status=SUCCESS | time=0ms
2019.03.21 04:21:01 INFO  ce[AWmeeuvpfejeH12FY31i][o.s.c.t.s.ComputationStepExecutor] Trigger refresh of Portfolios and Applications | status=SUCCESS | time=0ms
2019.03.21 04:21:01 INFO  ce[AWmeeuvpfejeH12FY31i][o.s.c.t.CeWorkerImpl] Executed task | project=niki-infra:gitlab-github-proxy | type=REPORT | id=AWmeeuvpfejeH12FY31i | submitter=rohit.verma@niki.ai | status=SUCCESS | time=9651ms

Configured sonar gitlab with access-token[all access granted]

But with all this, no sonar commits are published even when there are new code defects in sonar.

Please help, really want to get this functioning.