Skip to content

gitlab-runner exec: easily test builds locally

I just pushed a brand new feature to GitLab Runner: exec.

It allows you to run the jobs defined in .gitlab-ci.yml locally! In turn, this allows for faster testing cycles, and it makes it easier to fix broken builds.

The command supports any executor and supports all .gitlab-ci.yml options.

How to use it

  1. Install Bleeding Edge Runner release locally.
  2. Run the build: gitlab-runner exec docker my-job.

This will run my-job defined in the local .gitlab-ci.yml in a docker container.

Using exec with Docker

  1. Install docker-machine.
  2. Create a new docker VM: docker-machine create -d virtualbox runner
  3. Configure shell: eval $(docker-machine env runner)

Limitations:

  1. Some environment variables are not accurate: CI_BUILD_ID, CI_PROJECT_ID, etc.

Let me know what do you think about it.