Skip to content

detectGitlabMergeRequestContext

function detectGitlabMergeRequestContext(env?):
| GitlabMergeRequestContext
| null;

Defined in: src/ci/gitlab.ts:58

Reads the merge request’s API coordinates from GitLab CI’s predefined variables. CI_MERGE_REQUEST_IID is set in merge request pipelines; a branch pipeline instead gets CI_OPEN_MERGE_REQUESTS (group/project!iid[,...]), whose first entry’s IID is used as a fallback. Returns null when the context can’t be determined.

runGitlabComment never actually reaches the branch-pipeline fallback: it already requires CI_MERGE_REQUEST_DIFF_BASE_SHA to diff at all, which (like CI_MERGE_REQUEST_IID) GitLab only sets on merge request pipelines — so by the time this runs there, the direct CI_MERGE_REQUEST_IID path has always already matched. The fallback exists for a caller that determines its own base ref some other way and calls this function directly.

ProcessEnv = process.env

| GitlabMergeRequestContext | null