Hello everyone. I need help with a gitlab ci/cd setup issue.
- I setup gitlab-ce using docker and point a subdomain to it http://gitlab.mydomain.com
- The repository is a private repository and I expose the 22 port of the gitlab-ce container to port 1022 on my server so that I can use git clone ssh://git@gitlab.mydomain.com:1022/group/repo.git to clone the repostiry, which works fine
- I ran a gitlab-runner using docker on the same machine and registered it to the gitlab container
- Now I created a .gitlab-ci.yml file and try to test out gitlab’s CI/CD which kept failing since the runner seems always try to clone the project using the default http://gitlab.mydomain.com/group/repo.git path. I tried to add variables to .gitlab-ci.yml to set CI_REPOSITORY_URL but it didn’t work. I even tried to print out all the env variables from .gitlab-ci.yml but didn’t work. I also tried set the CI_REPOSITORY_URL direclty in gitlab’s project setting but still no luck. Please help, I already create a ssh key in the gitlab runner docker container and added the corresponding deploy key to my project’s CI/CD setting. The current .gitlab-ci.yml is as followed:
variables:
CI_REPOSITORY_URL: "git@gitlab.mydomain.com:group/repo.git"
GIT_STRATEGY: clone
GIT_DEPTH: 1
image: node:18
debug_job:
script:
- printenv
- echo "CI_REPOSITORY_URL = $CI_REPOSITORY_URL"
- echo "GIT_STRATEGY = $GIT_STRATEGY"
cache:
paths:
- node_modules/
before_script:
- pnpm install
test_job:
script:
- pnpm test
From the gitlab runner’s docker log, I kept on seeing the following pattern:
Checking for jobs... received job=26 repo_url=http://gitlab.mydomain.com/group/repo.git runner=Fu3hyn8aJ
Added job to processing list builds=1 job=26 max_builds=1 project=1 repo_url=http://gitlab.mydomain.com/group/repo.git
WARNING: Job failed: exit code 1
duration_s=2.162289021 job=26 project=1 runner=Fu3hyn8aJ
From the gitlab CI/CD page, it shows the following log and error:
Running with gitlab-runner 16.5.0 (853330f9)
on runner-1 Fu3hyn8aJ, system ID: r_MnXD6RINRzVY
Preparing the "docker" executor
00:02
Using Docker executor with image node:18 ...
Pulling docker image node:18 ...
Using docker image sha256:94616e9c776d52cd7ec1704871a6d4b615223673778ff392a609615e13ef99d0 for node:18 with digest node@sha256:a6385a6bb2fdcb7c48fc871e35e32af8daaa82c518900be49b76d10c005864c2 ...
Preparing environment
00:01
Running on runner-fu3hyn8aj-project-1-concurrent-0 via 7c489f0b99d8...
Getting source from Git repository
00:00
Fetching changes with git depth set to 1...
Initialized empty Git repository in /builds/group/repo/.git/
Created fresh repository.
remote: You are not allowed to download code from this project.
fatal: unable to access 'http://gitlab.mydomain.com/group/repo.git/': The requested URL returned error: 403
ERROR: Job failed: exit code 1
PLEASE HELP! Thanks a lot!