GitLab CI_JOB_TOKEN 未使用私有 python 存储库进行身份验证

问题描述 投票:0回答:1

我尝试在 GitLab CI 管道中使用

CI_JOB_TOKEN
从不同项目的包注册表安装 Python 包。

根据文档,我应该只需将我的项目添加到相应项目的白名单中并运行管道。

但是运行此命令时我总是收到以下 401 错误

pip install --extra-index-url https://__token__:[email protected]/api/v4/projects/<projId>/packages/pypi/simple <package>
Looking in indexes: https://pypi.org/simple, https://__token__:****@gitlab.com/api/v4/projects/<projId>/packages/pypi/simple
WARNING: 401 Error, Credentials not correct for https://gitlab.com/api/v4/projects/<projId>/packages/pypi/simple/<package>/
ERROR: Could not find a version that satisfies the requirement <package> (from versions: none)
ERROR: No matching distribution found for <package>
WARNING: 401 Error, Credentials not correct for https://gitlab.com/api/v4/projects/<projId>/packages/pypi/simple/pip/

我尝试完全删除允许列表保护,但仍然不起作用。

作为一种解决方法,我只是在 GUI 中的管道中添加了一个以访问令牌形式存在的秘密变量,这样它就可以工作了,但这似乎很麻烦,因为我需要每隔几周更新一次令牌。

我是否错过了文档中的任何内容并且

CI_JOB_TOKEN
无权访问这些注册表?

python authentication gitlab gitlab-ci token
1个回答
0
投票

sytech在评论中提供了答案。

使用用户名

gitlab-ci-token
而不是
__token__

© www.soinside.com 2019 - 2023. All rights reserved.