Merge requests


Merge requests

Merge requests enable collaboration

Pipelines can automatically test merge requests

Commits to a branch with a merge request cause multiple events:

  1. Push event to branch -> branch pipeline
  2. Merge request event -> merge request pipeline

Use rules to decide which jobs to run when

GitLab offers $CI_PIPELINE_SOURCE with event name


Merge request pipelines

What make them different

Only run when configured using the rules keyword

Have access to more pre-defined variables

Do not have access to protected variables


Rule templates

Pipelines often have many jobs

Rules will be repeated multiple times

Combine rules with templates to prevent repetition

.rule-only-web:
  rules:
  - if: $CI_PIPELINE_SOURCE == 'web'

job_name:
  extends:
  - .rule-only-web
  #...

Hands-On

See chapter Merge requests


Integration with SonarQube

Merge request decoration

Write scan results into merge request

Requires Developer Edition

Quality Gates

Wait for quality gates:

sonar-scanner -Dsonar.qualitygate.wait=true