Gitlab CI / CD:运行程序尝试克隆项目时未经授权

时间:2019-08-08 15:25:36

标签: gitlab gitlab-ci-runner

我尝试第一次将Gitlab CI / CD与GilLab Runner一起使用。 GitLab是一个自托管版本。

我在GitLab中有一个git项目。默认情况下,用户必须使用带私钥的SSH才能使用git命令。 但是我想指定访问控制设置为SSH和HTTPS。

对于该项目,我使用GitLab指定的令牌创建一个简单的.gitlab-ci.yml文件(具有单个测试步骤)和一个GitLab运行程序。

我运行作业时,发生以下错误:

Running with gitlab-runner 12.1.0 (de7731dd)
on BK_runner_Test3 hcVfxLhx
Using Shell executor...
Running on ns344345...
Fetching changes...
Reinitialized existing Git repository in /home/gitlab-runner/builds/hcVfxLhx/0/XXXXXXXXX/test/.git/
fatal: unable to access 'https://gitlab-ci-token:[MASKED]@gitlab.xxxxxxxx.com/XXXXXXXX/test.git/': The requested URL returned error: 500
ERROR: Job failed: exit status 1

最后,在Apache日志中,我发现了一个错误为401和500的请求。 因此,我认为当时的工作是尝试克隆项目。所以我尝试以下命令:

git clone https://gitlab-ci-token:[MASKED]@gitlab.xxxxxxxx.com/XXXXXXXX/test.git/

结果是错误401! 当然[MASKED]被正确的令牌代替,用于声明星期二赛跑者。

那么为什么出现此错误401?为了使用git命令授权作业,我在配置中错过了什么?


日志文件/var/log/gitlab/gitlab-rails/production.log中的更多信息

Started GET "/XXXXXXXX/test.git/info/refs?service=git-upload-pack" for 111.222.333.444 at 2019-08-08 15:39:05 +0200
Processing by Projects::GitHttpController#info_refs as */*
Parameters: {"service"=>"git-upload-pack", "namespace_id"=>"XXXXXXXX", "project_id"=>"test.git"}
Filter chain halted as :authenticate_user rendered or redirected
Completed 401 Unauthorized in 15ms (Views: 0.7ms | ActiveRecord: 1.4ms | Elasticsearch: 0.0ms)
Started GET "/XXXXXXXX/test.git/info/refs?service=git-upload-pack" for 111.222.333.444 at 2019-08-08 15:39:05 +0200
Processing by Projects::GitHttpController#info_refs as */*
Parameters: {"service"=>"git-upload-pack", "namespace_id"=>"XXXXXXXX", "project_id"=>"test.git"}
Completed 500 Internal Server Error in 12ms (ActiveRecord: 3.0ms | Elasticsearch: 0.0ms)

JWT::DecodeError (Nil JSON web token):

1 个答案:

答案 0 :(得分:0)

看来,在GitLab Rails中已正确验证/授权了Git请求,但是当将其传递给GitLab Workhorse以将数据实际发送到客户端时,某些授权会失败。

检查工作日志,以查看是否有更多信息。在Omnibus安装中,默认情况下它将位于/var/log/gitlab/gitlab-workhorse/中。我不确定是什么原因导致的,但是由于某种原因,不存在授权主力的标题。

确保您的GitLab版本与跑步者版本相当接近。我看到您正在运行Runner 12.1,因此GitLab也应该为12.1。

相关问题