Search code examples
gitdockergitlab-cigitlab-ci-runner

GitLab CI runner with Docker executor fails to clone repository


I would like to use GitLab CI on my institution's GitLab instance to run unit tests for my Python project.

I have written a simple job in my .gitlab-ci.yml file:

test-job:
  stage: test
  script:
    - echo "This job tests something"

I had defined a first runner with Shell executor on my machine.

When pushing new commits on the GitLab instance repo, the job ran successfully with this first runner.

I also successfully ran the job locally with: sudo gitlab-runner exec shell test-job

I then defined a second runner with Docker executor (and paused the first runner on the GitLab instance). I also added image: continuumio/miniconda3 right before stage: test in my .gitlab-ci.yml file.

When pushing to the remote repo, the job fails with this second runner, and returns the following error:

remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See http://gitlab2.xxx.xx/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'http://gitlab2.xxx.xx/xxx/xxx.git/'

I successfully ran the job locally with: sudo gitlab-runner exec docker test-job

What am I doing wrong to run this test using Docker executor when pushing to the GitLab instance?

Should I add variables to store credentials and access the GitLab instance? In that case how did the Shell runner succeed?


Solution

  • Adding a clone_url parameter for the runner with docker executor in my gitlab-runner config file on my machine (/etc/gitlab-runner/config.toml) fixed my issue (based on this GitLab CI/CD forum post).