Interview Prep/CI/CD/GitLab CI Failures

Merge request pipeline shows `Detached merge request pipeline` and `$CI_COMMIT_BRANCH` is empty.

AdvancedTroubleshootingGitLab CI Failures
Answer

Likely causes → MR pipelines do not set CI_COMMIT_BRANCH; they set CI_MERGE_REQUEST_* variables.

Diagnose → Print CI_PIPELINE_SOURCE and CI_MERGE_REQUEST_SOURCE_BRANCH_NAME.

Fix → Use CI_COMMIT_REF_NAME or MR variables in logic.

Prevent → Test rules in both branch and MR pipelines.

All CI/CD questions Roadmap: GitLab CI/CD

More on GitLab CI Failures