修复JWT::DecodeError (Nil JSON web令牌)为Gitlab运行器/ CI作业?



我试图在Gitlab-CI中安装一个简单的工作。它应该只是复制存储库中的大部分文件(.php)到另一个文件夹(从存储库到Apache的/var/www/html/…)。

输出如下:

Using Shell executor...
Preparing environment
Running on my.server...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialisierte existierendes Git-Projektarchiv in /home/gitlab-runner/builds/TyGXtawE/0/sdp-dev/ibo-php/.git/
fatal: unable to access 'https://gitlab-ci-token:[MASKED]@gitlab.sustainable-data-platform.org/sdp-dev/ibo-php.git/':
The requested URL returned error: 500

所以我可以找到相应的问题在/var/log/gitlab/gitlab-rails/production.log

Started POST "/api/v4/jobs/request" for ip.ip.ip.ip at 2022-04-26 14:27:41 +0200
Started GET "/sdp-dev/ibo-php.git/info/refs?service=git-upload-pack" for ip.ip.ip.ip at 2022-04-26 14:27:44 +0200
Processing by Repositories::GitHttpController#info_refs as */*
Parameters: {"service"=>"git-upload-pack", "repository_path"=>"sdp-dev/ibo-php.git"}
Filter chain halted as :authenticate_user rendered or redirected
Completed 401 Unauthorized in 14ms (Views: 1.3ms | ActiveRecord: 1.5ms | Elasticsearch: 0.0ms | Allocations: 4656)
Started GET "/sdp-dev/ibo-php.git/info/refs?service=git-upload-pack" for ip.ip.ip.ip at 2022-04-26 14:27:44 +0200
Processing by Repositories::GitHttpController#info_refs as */*
Parameters: {"service"=>"git-upload-pack", "repository_path"=>"sdp-dev/ibo-php.git"}
Completed 500 Internal Server Error in 34ms (ActiveRecord: 7.6ms | Elasticsearch: 0.0ms | Allocations: 7564)

JWT::DecodeError (Nil JSON web token):

lib/gitlab/jwt_authenticatable.rb:17:in `decode_jwt_for_issuer'
lib/gitlab/workhorse.rb:210:in `decode_jwt'
# ... stacktrace

我已经从"https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_amd64.rpm">安装了运行器,并从Gitlab的GUI给了它令牌。

Gitlab (v14.5.2)和runner (v14.10.0)在同一台机器上运行。

所有这些可能是一些cp -r的开销,但我想了解即将到来的更复杂的工作的错误。知道如何调试注册令牌吗?,如何发现问题?

更新

403 for Gitlab Runner from Gitlab?

似乎Gitlab -runner刚刚从Gitlab获得一个403 (forbidden)。所以我可能需要改变一些东西在相应的(Apache)。但是我如何调试这个(ERROR: Checking for jobs... forbidden)?

如何报名参赛?

有这个命令:sudo gitlab-runner register --url $URL --registration-token $REGISTRATION_TOKEN。但是,当我在这个命令中放入正确的数据(URL, REGISTRATION_TOKEN)时(不使用bash变量!),我再次被要求输入相同的数据(URL, TOKEN),我只是执行c/p。例如:Type the URL [MY_URL]:,然后输入c/pMY_URL,按回车键。这样可以吗?

令牌/不健康的运行程序问题

在gitlab中创建新令牌并注册新运行器后没有成功,也在gitlab更新到v14.10之后。

但是我可以在/var/log/messages中看到一些问题。

systemd: Started GitLab Runner.
gitlab-runner: Runtime platform                                  #033[0;m  arch#033[0;m=amd64 os#033[0;m=linux pid#033[0;m=20848 revision#033[0;m=c6bb62f6 version#033[0;m=14.10.0
gitlab-runner: Starting multi-runner from /etc/gitlab-runner/config.toml...#033[0;m  builds#033[0;m=0
gitlab-runner: Running in system-mode.                           #033[0;m
gitlab-runner: #033[0;m
gitlab-runner: Configuration loaded                              #033[0;m  builds#033[0;m=0
gitlab-runner: listen_address not defined, metrics & debug endpoints disabled#033[0;m  builds#033[0;m=0
gitlab-runner: [session_server].listen_address not defined, session endpoints disabled#033[0;m  builds#033[0;m=0
gitlab-runner: #033[31;1mERROR: Checking for jobs... forbidden             #033[0;m  #033[31;1mrunner#033[0;m=TyGXtawE
gitlab-runner: #033[31;1mERROR: Checking for jobs... forbidden             #033[0;m  #033[31;1mrunner#033[0;m=iU4sqj-p
gitlab-runner: #033[31;1mERROR: Checking for jobs... forbidden             #033[0;m  #033[31;1mrunner#033[0;m=TyGXtawE
gitlab-runner: #033[31;1mERROR: Checking for jobs... forbidden             #033[0;m  #033[31;1mrunner#033[0;m=iU4sqj-p
gitlab-runner: #033[31;1mERROR: Checking for jobs... forbidden             #033[0;m  #033[31;1mrunner#033[0;m=TyGXtawE
gitlab-runner: #033[31;1mERROR: Runner {URL}/{token} is not healthy and will be disabled!#033[0;m
gitlab-runner: #033[31;1mERROR: Checking for jobs... forbidden             #033[0;m  #033[31;1mrunner#033[0;m=iU4sqj-p
gitlab-runner: #033[31;1mERROR: Runner {URL}/{token} is not healthy and will be disabled!#033[0;m

我对listen_address not defined, metrics & debug endpoints disabledChecking for jobs... forbidden感兴趣。

你可以在SO的其他地方看到这个问题,但我找不到解决方案(谷歌等)。

吗?https://gitlab.com/gitlab-org/gitlab-runner/-/issues/28965

你可以试试:

  • 创建新令牌

  • 更新Gitlab

最新更新