我们有 GitLab 的盒装版本。里面有一个团体叫
lab
。该组中有许多历史悠久的项目(PHP 库)。该小组还创建了几个新项目。在某些时候,新项目不再作为 GitLab CI 中的 Composer 依赖项安装:
You must be using the interactive console to authenticate Now trying to download from source Syncing lab/blah_blah (1.0.0) into cache
[RuntimeException]
Failed to execute git clone --mirror -- 'https://gitlabdev.our-domain/lab/blah_blah.git' '/opt/composer/cache/vcs/https---gitlabdev.our-domain-lab-blah_blah.git/'
Cloning into bare repository '/opt/composer/cache/vcs/https---gitlabdev.our-domain-lab-blah_blah.git'...
Warning: Permanently added the ECDSA host key for IP address '172.20.24.27' to the list of known hosts.
remote:
remote: ========================================================================
remote:
remote: The project you were looking for could not be found or you don't have permission to view it.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
在本地,一切正常(GitLab 令牌已安装)。当我尝试在项目根目录中使用我的个人令牌创建
auth.json
时,GitLab CI 开始安装新的依赖项,但这不是正确的解决方案。新旧项目都已成功包含在 GitLab 包注册表中。
我的作曲家 JSON:
{
"name": "vendor_name/test-gitlab-auth",
"description": "description",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
{
"name": "stas",
"email": "[email protected]"
}
],
"require": {
"lab/old_project_1": "*", // ok
"lab/old_project_2": "*", // ok
"lab/blah_blah": "*" // failture
},
"repositories": [
{
"type": "composer",
"url": "https://gitlabdev.our-domain/api/v4/group/9/-/packages/composer" // lab group registry
}
]
}
为什么 GitLab 对新旧项目的行为可能不同?据我所知,他们在 GitLab 中的设置是相同的,并且拥有权限。
GitLab CI 中的 Composer 依赖项不应该有任何问题。为了确保这一点,请仔细检查是否:
CI代币拥有新项目的正确访问权限。
.gitlab-ci.yml
文件与非工作新项目类似。
在 CI 环境中清除 Composer 缓存会有所帮助。
before_script:
- composer clear-cache
script:
- composer install
CI 中使用的GitLab 令牌的范围涵盖了所需的操作。
新项目的可见性设置与旧项目相同。