skip to Main Content

I setup up gitlab-runner on my machine to run from a docker container as per these instructions. Then I try to run it with this command:

docker run -v /etc/gitlab-runner:/etc/gitlab-runner --rm -it gitlab/gitlab-runner exec docker test

I expect that this will run the ‘test’ stage of my .gitlab-ci.yml file using the ‘docker’ executor. Instead it exits with this message:

fatal: not a git repository (or any of the parent directories): .git

I also tried it with "–env CI_PROJECT_DIR=." but got the same result. Do I need to set some variable so that it will know what Git repo to clone? Or is it easier to just install the ‘gitlab-runner’ binary on my Linux box and use that for CLI testing?

2

Answers


  1. Chosen as BEST ANSWER

    From the docs:

    If you want to use the docker executor with the exec command, use that in context of docker-machine shell or boot2docker shell. This is required to properly map your local directory to the directory inside the Docker container.

    gitlab-runner exec docker ...
    

    doesn't seem to work at all in CLI.


  2. docker run –rm -v $PWD:$PWD -v /var/run/docker.sock:/var/run/docker.sock -v /opt/gitlab-runner/config:/etc/gitlab-runner –workdir $PWD gitlab/gitlab-runner exec docker deploy. Option –workdir is the key.

    Use GitLab CI to run tests locally?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search