GitLab CI best practices

MSAL

Apply GitLab CI/CD best practices to .gitlab-ci.yml. This includes adding workflow:rules to prevent duplicate pipelines, setting interruptible: true and retry in the default section, configuring artifacts:expire_in, setting a job timeout, and ordering the keywords consistently.

org.openrewrite.gitlab.BestPractices
mod run . --recipe=org.openrewrite.gitlab.BestPractices

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Migrate only/except to rules
  2. Add workflow rules - if: $CI_PIPELINE_SOURCE == 'merge_request_event' if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never if: $CI_COMMIT_BRANCH
  3. Add interruptible
  4. Add retry configuration 2
  5. Add artifacts expire_in 1 week
  6. Add job timeout 1 hour
  7. Order GitLab CI keywords