GitLab。使用 gitlab-ci-token 和 $CI_BUILD_TOKEN $CI_REGISTRY 导致错误

dan*_*il_ 3 gitlab docker gitlab-ci gitlab-ci-runner

我使用 gitlab.com 已经大约一年了。我没有做任何更改,但我开始收到这样的错误:

Error response from daemon: Get "https://registry-1.docker.io/v2/": unauthorized: incorrect username or password
Run Code Online (Sandbox Code Playgroud)

我使用的命令:

 - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
Run Code Online (Sandbox Code Playgroud)

我该如何修复它?

syt*_*ech 7

$CI_BUILD_TOKEN以及所有其他CI_BUILD_*变量在 GitLab v9.0(2017 年 3 月)中已弃用,并在 GitLab 16.0(2023 年 5 月 22 日)中删除,并由$CI_JOB_TOKEN.

因此,您需要更改脚本来更新此变量:

 - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Run Code Online (Sandbox Code Playgroud)