Gitlab ci令牌用户无法克隆存储库
我正在尝试设置docker runner并成功地向gitlab ce注册了该runner。但是,当作业运行时,它总是失败,原因如下:Gitlab ci令牌用户无法克隆存储库,gitlab,gitlab-ci-runner,Gitlab,Gitlab Ci Runner,我正在尝试设置docker runner并成功地向gitlab ce注册了该runner。但是,当作业运行时,它总是失败,原因如下: Running with gitlab-ci-multi-runner 1.10.2 (d171b73) Using Docker executor with image python:3.4 ... Starting service postgres:latest ... Pulling docker image postgres:latest ... Wait
Running with gitlab-ci-multi-runner 1.10.2 (d171b73)
Using Docker executor with image python:3.4 ...
Starting service postgres:latest ...
Pulling docker image postgres:latest ...
Waiting for services to be up and running...
Pulling docker image python:3.4 ...
Running on runner-b35ff618-project-96-concurrent-0 via toucan...
Cloning repository...
Cloning into '/builds/amrstratus/webportal'...
fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.xxxxxxxxx/amrstratus/webportal.git/': Failed to connect to gitlab.xxxxxx port 443: Connection refused
ERROR: Build failed: exit code 1
我试图简单地克隆存储库,但得到了一个类似的错误:
root@toucan:/tmp# git clone https://gitlab-ci-token:b35ff618453c702944c736668e1c2c@gitlab.xxxxxxxx/amrstratus/webportal.git/
Cloning into 'webportal'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab-ci-token:xxxxxxxxxxx@gitlab.xxxxxxxx/amrstratus/webportal.git/'
通过https访问似乎工作正常,其他一切似乎都正常
有什么想法吗?我完全卡住了
系统详细信息:
Debian 8 (Jessie)
GitLab 8.16.2
GitLab Shell 4.1.1
GitLab Workhorse v1.3.0
GitLab API v3
Git 2.10.2
Ruby 2.3.3p222
Rails 4.2.7.1
PostgreSQL 9.6.1
请注意,可能存在两个问题 关于令牌本身(以及
致命:身份验证失败
),请参阅
现在为每个生成安全地生成CI令牌。它在$CI\u BUILD\u令牌中提供
如果您要从.gitlab ci.yml
(就像我们一样)克隆不同的存储库,那么最好使用SSH
另一个解决方案是使用您的个人专用令牌:
git clone https://:@gitlab.anydomainhere.com/developers/.git
(请注意,此令牌允许访问您的所有项目)
另一个问题与Docker有关:致命:无法访问
您需要确保可以与Gitlab实例通信(或在中)。
而且。我知道这是一个老问题,但是,对我来说,解决这个问题的是根据对workhorse的调整
将/etc/gitlab/gitlab.rb
修改如下:
取消对此行的注释
gitlab_workhorse['enable'] = true
加上这两行
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
然后修改Web服务器配置,将反向代理指向此服务器,而不是unicorn。尽管已经给出了解决方案,但使用了个人令牌。
如前所述,它可能会失败,因为如果使用CI_BUILD_令牌/CI_JOB_令牌进行克隆,则该令牌仅对该作业运行有效。
因此,如果希望每次拉动都能通过运行程序进行,可以在拉动时指定url:
git pull https://gitlab-ci-token:$CI_JOB_TOKEN@gitlab.anydomainhere.com/developers/<projectname>.git
git拉https://gitlab-ci-token:$CI_工作_TOKEN@gitlab.anydomainhere.com/developers/.git
这样,每次拉取请求都会使用新令牌。谢谢,您的帖子帮助我解决了问题。这不是身份验证问题,而是docker和my firewall阻止请求的相关问题。使用docker运行python:3.4/usr/bin/curl帮助我解决了这个问题。
git pull https://gitlab-ci-token:$CI_JOB_TOKEN@gitlab.anydomainhere.com/developers/<projectname>.git