1

I have created a custom Gitlab CI/CD runner. I used project based token.

New-Item -Path 'C:\GitLab-Runner' -ItemType Directory

cd 'C:\GitLab-Runner'

Invoke-WebRequest -Uri "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-amd64.exe" -OutFile "gitlab-runner.exe"

.\gitlab-runner.exe install
.\gitlab-runner.exe start

./gitlab-runner.exe register --url http://gitlab.my-company.net/ --registration-token $REGISTRATION_TOKEN

The token I get from the UI,

enter image description here

But I am getting this 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.

Imran Qadir Baksh - Baloch
  • 32,612
  • 68
  • 179
  • 322
  • Where, exactly are you seeing that error? When registering the runner or trying to run a job on that runner? – sytech Apr 06 '23 at 18:30

1 Answers1

1

You need first to check the version of GitLab used.

As noted in "Registering runners (deprecated)"

The ability to pass a runner registration token was deprecated in GitLab 15.6 and is planned for removal in 17.0, along with support for certain configuration arguments

GitLab plans to introduce a new GitLab Runner token architecture, which introduces a new method for registering runners and eliminates the legacy runner registration token.

Thread 82118 also follows that issue:

Did you perhaps have some form of LDAP or SSO authentication in place on Gitlab?
I ran into an issue where our runner was trying to authenticate with LDAP/Kerberos under the hood, which was failing.
We thought it was an issue with the CI_JOB_TOKEN, but that was not the issue.

The OP Imran Qadir Baksh - Baloch adds in the comments:

As shown in "Gitlab Pipeline failing "remote: HTTP Basic: Access denied"", adding clone_url fixed it.

Now, I am getting

Exception calling "WriteAllText" with "2" argument(s): 
"Access to the path 'c:\builds\xxx\xxx.tmp\CI_SERVER_TLS_CA_FILE' is denied."

And that is fixed by using mcr.microsoft.com/dotnet/sdk:6.0.202-windowsservercore-ltsc2019, as mentioned in gitlab-org/gitlab-runner issue 27891.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • My Gitlab version is 15.2.5-ee – Imran Qadir Baksh - Baloch Apr 06 '23 at 15:09
  • Although gitlab has "deprecated" registration, they have not yet introduced its replacement. Clarified in [this thread](https://gitlab.com/gitlab-org/gitlab/-/issues/380872#note_1199851762) it is not yet actually deprecated, but rather _will be_ deprecated. – sytech Apr 06 '23 at 18:28
  • @sytech Good point. Let's wait for the OP's feedback. – VonC Apr 06 '23 at 20:28
  • Adding clone_url fixed it https://stackoverflow.com/questions/72381700/gitlab-pipeline-failing-remote-http-basic-access-denied. Now, I am getting Exception calling "WriteAllText" with "2" argument(s): "Access to the path 'c:\builds\xxx\xxx.tmp\CI_SERVER_TLS_CA_FILE' is denied." – Imran Qadir Baksh - Baloch Apr 07 '23 at 04:11
  • Second issue is also fixed by using `mcr.microsoft.com/dotnet/sdk:6.0.202-windowsservercore-ltsc2019` https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27891 – Imran Qadir Baksh - Baloch Apr 07 '23 at 04:44
  • 1
    @ImranQadirBaksh-Baloch Thank you for your feedback. I have included your comments in the answer for more visibility. – VonC Apr 07 '23 at 10:59