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

Issues not reported #155

Closed Czternasty closed 6 years ago

Czternasty commented 6 years ago

Hello Gabriel,

I'm trying to setup the plugin on Sonar 7.1, but I can't make it works without using the -Dsonar.analysis.mode=preview parameter.

(Between each run, I create obvious Sonar issues) With -Dsonar.analysis.mode=preview my maven log says :

[INFO] Executing post-job GitLab Commit Issue Publisher [INFO] Report status=success, desc=SonarQube reported 1 issue, with 1 minor

And issues are posted on Gitlab, but are not saved in SonarQube.

If I remove the -Dsonar.analysis.mode=preview, the maven log is:

[INFO] Executing post-job GitLab Commit Issue Publisher [INFO] Waiting quality gate to complete... [INFO] Waiting quality gate to complete... [INFO] Waiting quality gate to complete... [INFO] Waiting quality gate to complete... [INFO] Waiting quality gate to complete... [INFO] Waiting quality gate to complete... [INFO] Quality gate status: ERROR [ERROR] Open Issues: 3 > 0 [INFO] Reopened Issues : 0 [INFO] Report status=failed, desc=SonarQube reported QualityGate is error, with 1 error and 1 ok, no issues

So the created issue is not reported on the commit.

My mvn command is:

mvn clean install -U sonar:sonar -Dsonar.host.url=xxx -Dsonar.login=xxx -Dsonar.branch.name=$GIT_BRANCH -Dsonar.gitlab.commit_sha=$GIT_COMMIT -Dsonar.gitlab.ref_name=$GIT_COMMIT

I've tested with the version 3 and with the last snapshot of the plugin.

So does the plugin support Sonar 7.1? And does the plugin works with default sonar.analysis.mode?

Thanks.

gabrie-allaigre commented 6 years ago

Hi, Change -Dsonar.gitlab.ref_name=$GIT_COMMIT by -Dsonar.gitlab.ref_name=$GIT_BRANCH

Czternasty commented 6 years ago

Hi Gabriel,

It's work, thank you a lot!

cdtinney commented 5 years ago

I'm having the same issue.

Running the following script:

mvn --batch-mode -e -X verify sonar:sonar \
  -Dsonar.branch=${GIT_BRANCH} \
  -Dsonar.gitlab.project_id=${config.gitLabProjectId} \
  -Dsonar.gitlab.commit_sha=${GIT_COMMIT} \
  -Dsonar.gitlab.ref_name=${GIT_BRANCH} \

Results in:

Report status=failed, desc=SonarQube reported QualityGate is error, with 5 error and 1 warn and 4 ok, no issues

The comment is created but it reports no issues. It only shows the failed quality gate.