Merge requests enable collaboration
Pipelines can automatically test merge requests
Commits to a branch with a merge request cause multiple events:
Use rules to decide which jobs to run when
GitLab offers $CI_PIPELINE_SOURCE
with event name
Enable jobs lint
, audit
, build
and test
for merge requests and pushes
job_name:
rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == "main"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
#...
Prevent deploy
in merge requests
job_name:
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" || $CI_COMMIT_REF_NAME == "live"'
#...
Prevent trigger
in merge requests
job_name:
rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == "main"'
#...
See new .gitlab-ci.yml
:
git checkout 160_gitlab_ci/140_merge_requests -- '*'