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
121 stars 21 forks source link

Branch analysis fails when sonar.gitlab.merge_request_discussion is enabled globally #17

Open stalb opened 3 years ago

stalb commented 3 years ago

If sonar.gitlab.merge_request_discussion is enabled globally for the plugin on the sonarqube instance, you have to define it to false on branch analyses or the pipeline will fail to add comments for detected issues because merge request iid is missing.

error:

INFO: Executing post-job 'Final report'
INFO: Turn debug info on to get more details (sonar-scanner -X -Dsonar.verbose=true ...).
INFO: Executing post-job 'GitLab Commit Issue Publisher'
INFO: Will execute CommitPublishPostJob of GitlabPlugin.
INFO: GitLab plugin is enabled
INFO: Waiting quality gate to complete...
INFO: Quality gate status: ERROR
INFO: Reliability Rating on New Code : 1
INFO: Security Rating on New Code : 1
ERROR: Maintainability Rating on New Code: 4 > 1
INFO: Will try to update review comments.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:17.288s
INFO: Final Memory: 16M/70M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: SonarQube failed to complete the review of this commit: The merge request iid must be provided.
ERROR: Caused by: The merge request iid must be provided.

Expected behavior: the sonar.gitlab.merge_request_discussion should be used only for merge request analyses.
For branch analyses it should be ignored.