Job failed with download code error

Hello everyone. I need help with a gitlab ci/cd setup issue.

  1. I setup gitlab-ce using docker and point a subdomain to it
  2. 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:// to clone the repostiry, which works fine
  3. I ran a gitlab-runner using docker on the same machine and registered it to the gitlab container
  4. 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 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:

image: node:18

    - printenv

    - node_modules/

  - pnpm install 

    - pnpm test

From the gitlab runner’s docker log, I kept on seeing the following pattern:

Checking for jobs... received                       job=26 repo_url= runner=Fu3hyn8aJ
Added job to processing list                        builds=1 job=26 max_builds=1 project=1 repo_url=
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
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
Running on runner-fu3hyn8aj-project-1-concurrent-0 via 7c489f0b99d8...
Getting source from Git repository
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 '': The requested URL returned error: 403
ERROR: Job failed: exit code 1

PLEASE HELP! Thanks a lot!

From my mac, I can clone the project using git clone ssh:// where 1022 is the port I exposed from the gitlab container.

I tried setting variables with CI_REPOSITORY_URL, GIT_STRATEGY etc… but it didn’t seem to work. The runner always using as the url to download code.

Any help will be deeply appreciated.