Pull Request Analysis in GitLab without using detached pipeline ("only: merge_requests")

Hi, SonarQube reads a bunch of “only: merge_requests” specific environment variables:

  • CI_MERGE_REQUEST_IID (Mandatory to trigger a MR decoration)
  • CI_MERGE_REQUEST_SOURCE_BRANCH_NAME (Mandatory to trigger a MR decoration)
  • CI_MERGE_REQUEST_TARGET_BRANCH_NAME (Optional, will use the main branch as default)
  • CI_MERGE_REQUEST_PROJECT_URL (Required to have the link to the MR from SQ PR view)
    (+ others environment variable not specific to only: merge_requests)

Keep in mind that its internal implementation, quite specific, and if you choose to “cheat” by providing these env variables yourself, things might break in the future without notice (=when the implementation change).

About the “conflicts with other GitLab CI stages/processes”, do you want to elaborate? Anything we can do on SQ side to ease the pain?