Skip to content

Instantly share code, notes, and snippets.

@DrPsychick
Last active September 1, 2024 10:03
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

@AmineDjeghri
Copy link

I found one and it works perfectly : https://github.com/firecow/gitlab-ci-local

you just need to run : gitlab-ci-local in the gitlab repository and it does the whole job !

@DrPsychick
Copy link
Author

That's even better, I will definitely try that!

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