Skip to content

Instantly share code, notes, and snippets.

@DrPsychick
Last active February 2, 2024 08:18
Show Gist options
  • Save DrPsychick/b92c2653c1132c3be6da2c3bb42905d4 to your computer and use it in GitHub Desktop.
Save DrPsychick/b92c2653c1132c3be6da2c3bb42905d4 to your computer and use it in GitHub Desktop.
Run gitlab-ci jobs locally

Run/Test GitLab CI Pipeline jobs locally

  • cd into your project directory

Hints

Run once

docker run --rm --name gitlab-runner -w $PWD \
  -v $PWD:$PWD -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest exec docker <job>

Run multiple times (keep runner in the background)

start a gitlab-runner locally in the background

docker run --rm -d \
  --name gitlab-runner \
  -v $PWD:$PWD \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest

execute a pipeline job locally

  • If you use template jobs (.test) then specify those as job.
docker exec -it -w $PWD gitlab-runner gitlab-runner exec docker <job>

stop & remove runner

docker stop gitlab-runner

for MacOS + Rancher Desktop

  • SSH into Rancher VM: LIMA_HOME="$HOME/Library/Application Support/rancher-desktop/lima" "/Applications/Rancher Desktop.app/Contents/Resources/resources/darwin/lima/bin/limactl" shell 0

Credits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment