Gitlab Runner registration return (401 Unauthorized)
Asked Answered
S

1

5

We have installed gitlab runner on redhat server but we can't register it with our gitlab instance as it is protected (we need to login before it shows HTTPS).

When we clone the project repository:

git clone https://domain\.com/project.git

It asks for username and password and if we store credentials in a file or cache like

git config --global credential.helper 'store --file ~/.my-credentials'

it will ask the first time only for authentication when cloning => my-credentials will contains the raw username/password but it solves the problem of being asked for authentification each time.

How can we do the same things with the runner in order to register it to our gitlab : when we run

gitlab-runner register --url http://domain\.com/gitlab/ -r 1TqfdYFsJsdsdLNc-7J

we got immediately the below error without asking us for username/password :

ERROR: Registering runner... failed                 runner=1TqfdYFs status=401 Unauthorized
PANIC: Failed to register the runner. You may be having network problems.

we know that the runnercan't access our gitlab because of the authentification needed but we don't know how to solve it we tried many things like saving credentials in git cache but it seems that they are not connected or use the same things.

Any ideas please ?

Sync answered 12/7, 2021 at 15:57 Comment(0)
A
9

I see that you are trying to register your runner with http method. Try registering with https instead. This resolved the issue for me.

gitlab-runner register --url https://domain\.com/gitlab/ -r 1TqfdYFsJsdsdLNc-7J
Ancillary answered 11/8, 2021 at 15:21 Comment(2)
Thanks for your response i tried both but the same issue, any other ideas ?Sync
We had to change our runner server to be in the same network of our gitlabe instance server and it works fine, it's a turn around of the issuSync

© 2022 - 2024 — McMap. All rights reserved.