javamachr / 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
123 stars 23 forks source link

SonarQube GitLab Plugin Not Posting Scan Results as Comments #38

Open JavayVeneno opened 3 months ago

JavayVeneno commented 3 months ago

Hello, after trying it out, my sonar-gitlab-plugin didn't post the scan results as comments in GitLab. Is there a command in GitLab CI for this?

This is my installation environment, the versions of SonarQube and the GitLab plugin, and the CI script:

SonarQube: 9.9.5 GitLab: 17.0 sonar-gitlab-plugin: 5.4.0 The CI script is roughly as follows:

mvn $MAVEN_CLI_OPTS verify sonar:sonar \ -DskipTests \ -Dsonar.host.url=${SONAR_HOST_URL} \ -Dsonar.login=${SONAR_TOKEN} \ -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} \ -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME} \ -Dsonar.gitlab.project_id=${CI_PROJECT_PATH} \ -Dsonar.gitlab.url=http://192.168.0.110:9000 \ -Dsonar.gitlab.api_version=v4 \ -Dsonar.gitlab.user_token=${GITLAB_USER_TOKEN} \ -Dsonar.gitlab.merge_request_discussion=true \ -Dsonar.gitlab.json_mode=CODECLIMATE \ -Dsonar.gitlab.failure_notification_mode=commit-status \ -Dmaven.compile.skip=true \ -Dsonar.projectKey=784-idp_784-IDP_AZA5zwnUWJ1OnTNqRY69

echo "SonarQube analysis completed."

Awaiting Your Response

JavayVeneno commented 3 months ago

I've identified the issue: when my QUALITY GATE fails, it causes my SonarQube analysis to fail, and consequently, the CommitPublishPostJob is not executed. When my entire project succeeds, the CommitPublishPostJob is executed. When I added - sonar.gitlab.comment_no_issue=true (which adds comments even when there are no issues), and I submitted code without any issues, the quality check passed and it triggered the comment.

Is it possible to ignore this quality gate failure and continue with subsequent operations?

softreigns commented 2 months ago

sonar.gitlab.quality_gate_fail_mode=true sonar.qualitygate.wait=false