Gitlab Fastlane

Gitlab Fastlane is a Ruby gem that allows developers to run GitLab CI pipelines locally before opening merge requests. This tool helps ensure that CI checks pass before creating merge requests by running the pipeline locally, checking for uncommitted changes, and tagging commits with validation markers.

Installation

Install the gem by executing:

gem install gitlab-fastlane

Or add it to your Gemfile:

gem 'gitlab-fastlane'

Prerequisites

This gem requires gitlab-ci-local to run pipelines locally. Install it using npm:

npm install -g gitlab-ci-local

For alternative installation methods, visit: https://github.com/firecow/gitlab-ci-local

Setup

Configure your CI pipeline to skip validated jobs while keeping the pipeline visible. For each job in your .gitlab-ci.yml, add these rules (replace <stage_name> with the actual stage like quality, test, or build):

rules:
  - if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "master"
    when: always
  - if: $CI_COMMIT_MESSAGE =~ /Gitlab Fastlane passed:.*\b<stage_name>\b/
    when: manual
    allow_failure: true
  - when: on_success

Example for a job in the quality stage:

rubocop:
  stage: quality
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "master"
      when: always
    - if: $CI_COMMIT_MESSAGE =~ /Gitlab Fastlane passed:.*\bquality\b/
      when: manual
      allow_failure: true
    - when: on_success
  script:
    - bundle exec rubocop

This configuration:

  • Creates the pipeline on all branches (allowing visibility of all jobs)
  • Makes validated jobs manual/skippable (won't block the pipeline)
  • Always runs jobs on main/master branches
  • Runs jobs normally on feature branches without validation tags

Finally, you will want to either allow MRs to be merged without the pipeline being successful, or to consider skipped pipelines to be successful. This can be done in a repository's Settings > Merge requests > Merge checks.

If you need to re-run validated jobs (e.g., after amending a commit), you can either:

  1. Manually trigger the job in GitLab CI
  2. Remove the validation tag from the commit message and run Fastlane again

Usage

gitlab-fastlane run [options]

This will:

  1. Check for unstaged/untracked/uncommited files and warn if found
  2. Run your GitLab CI pipeline locally using gitlab-ci-local
  3. Amend the most recent commit with a validation tag

Options

  • --enable-artifacts - Enable artifact creation during pipeline run (disabled by default to keep your workspace clean)

Technical aspects

  • On how to get started developing, check the HACKING file
  • On what are the code standards, check the CONTRIBUTING file
  • On how to install, check the DEPLOYING file
  • On how to keep the application up and running, check the MAINTENANCE file
  • On how to recover from disasters, check the DISASTER_RECOVERY file

License

Copyright - All rights reserved to Irya Solutions