This solves the initial issue, and the external job is now correctly displayed in the merge request pipeline. But in this case, the global comment does not display the issues, but always the message "SonarQube analysis reported no issues.". It still detects that the quality gate is failed, so that's unclear to me why this happens. Also when I go into SonarQube, I can see the issues listed for this branch analysis.
Maybe I'm not using the configuration correctly, here's what I have so far:
(I initialy didn't use the -Dsonar.gitlab.ci_merge_request_iid=${CI_MERGE_REQUEST_IID} and -Dsonar.gitlab.merge_request_discussion=true, and I saw no difference when adding them, so I'm probably misusing them as well.)
After trying to read through the plugin source code, my guess is that it's because the ref_name parameter is used at two different places:
Maybe it would be possible to add an additional parameter -Dsonar.gitlab.ci_merge_request_ref_path, so that we can provide both -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}, for issues retrieval, and -Dsonar.gitlab.ci_merge_request_ref_path=${CI_MERGE_REQUEST_REF_PATH} so the external job is correctly part of the merge request pipeline ?
Hello,
I encoutered an issue similar to what's described in this ticket: https://github.com/gabrie-allaigre/sonar-gitlab-plugin/issues/211
So I tried the solution from this comment https://github.com/gabrie-allaigre/sonar-gitlab-plugin/issues/211#issuecomment-530736404 , which is to use
-Dsonar.gitlab.ref_name=${CI_MERGE_REQUEST_REF_PATH}
instead of-Dsonar.gitlab.ref_name="${CI_COMMIT_REF_NAME}"
.This solves the initial issue, and the external job is now correctly displayed in the merge request pipeline. But in this case, the global comment does not display the issues, but always the message "SonarQube analysis reported no issues.". It still detects that the quality gate is failed, so that's unclear to me why this happens. Also when I go into SonarQube, I can see the issues listed for this branch analysis.
Maybe I'm not using the configuration correctly, here's what I have so far:
(I initialy didn't use the
-Dsonar.gitlab.ci_merge_request_iid=${CI_MERGE_REQUEST_IID}
and-Dsonar.gitlab.merge_request_discussion=true
, and I saw no difference when adding them, so I'm probably misusing them as well.)After trying to read through the plugin source code, my guess is that it's because the
ref_name
parameter is used at two different places:${CI_BUILD_REF_NAME}
, it works, and when its value is${CI_MERGE_REQUEST_REF_PATH}
it doesn't.${CI_BUILD_REF_NAME}
, it has no link to the MR and creates a new pipeline for the branch, and when its value is${CI_MERGE_REQUEST_REF_PATH}
it correctly posts the comment into the existing merge request pipeline.Maybe it would be possible to add an additional parameter
-Dsonar.gitlab.ci_merge_request_ref_path
, so that we can provide both-Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}
, for issues retrieval, and-Dsonar.gitlab.ci_merge_request_ref_path=${CI_MERGE_REQUEST_REF_PATH}
so the external job is correctly part of the merge request pipeline ?