[英]Error pulling packages from gitlab private repository in CI job
As part of a gitlab CI job, I am using pip to install internally-developed packages that are stored using gitlab pypi.作为 gitlab CI 作业的一部分,我使用 pip 安装内部开发的包,这些包使用 gitlab pypi 存储。 When I attempt to run
pip install <PACKAGE_NAME>
, I get the following error:当我尝试运行
pip install <PACKAGE_NAME>
时,出现以下错误:
WARNING: 401 Error, Credentials not correct for https://<GITLAB_URL>/api/v4/projects/<PROJECT_ID>/packages/pypi/simple/<PACKAGE_NAME>/
ERROR: Could not find a version that satisfies the requirement <PACKAGE_NAME> (from versions: none)
ERROR: No matching distribution found for <PACKAGE_NAME>
I am using a pip.conf file like the following:我正在使用 pip.conf 文件,如下所示:
[global]
extra-index-url =
https://__token__:<CI_JOB_TOKEN_SUBBED_IN_EXTERNALLY>@<GITLAB_URL>/api/v4/projects/<PROJECT_ID>/packages/pypi/simple
The install using the same pip.conf works fine on a workstation using my personal api token instead of the CI Job token.使用相同的 pip.conf 安装在使用我个人 api 令牌而不是 CI 作业令牌的工作站上可以正常工作。 What might be causing this problem?
什么可能导致这个问题?
It turns out that while __token__
works fine for personal tokens, it does not work for CI tokens;事实证明,虽然
__token__
适用于个人代币,但它不适用于 CI 代币; it needs to be gitlab-ci-token
.它需要是
gitlab-ci-token
。 The following file works fine:以下文件工作正常:
[global]
extra-index-url =
https://gitlab-ci-token:<CI_JOB_TOKEN_SUBBED_IN_EXTERNALLY>@<GITLAB_URL>/api/v4/projects/<PROJECT_ID>/packages/pypi/simple
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.