Skip to content

Instantly share code, notes, and snippets.

@juliangaal
Last active November 2, 2023 08:48
Show Gist options
  • Save juliangaal/fba78768f9fd2a81809bdc206a38cae8 to your computer and use it in GitHub Desktop.
Save juliangaal/fba78768f9fd2a81809bdc206a38cae8 to your computer and use it in GitHub Desktop.
Run gitlab runner locally
#!/bin/bash
set -e
# Run gitlab runner locally
# Prerequisite: non-root docker
#
# Usage: _gitlab_runner <BUILD_TAG (Default: build)>
function _gitlab_runner() {
TARGET=${1:-build}
[[ ! -f ".gitlab-ci.yml" ]] && echo ".gitlab-ci.yaml not found. Make sure to run this in correct directory" && return 1;
docker run --entrypoint bash --network=host --rm -w $PWD -v $PWD:$PWD -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest -c "git config --global --add safe.directory '*' && gitlab-runner exec docker ${TARGET}"
}
@juliangaal
Copy link
Author

Confirmed working as of 11/2023

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