Bootstrap

「GitLab CI/CD」- You are not allowed to download code from this project @20210402

问题描述

在 GitLab CI/CD 中,执行 Pipeline 产生如下错误:

Running with gitlab-runner 12.6.0 (ac8e767a)
  on ci-node Je2FxKTm
Using Docker executor with image python:3.6 ...
Pulling docker image python:3.6 ...
Using docker image sha256:cf1a689bcf55b9c83c397a6aa919ddfd7d05cb12bab4fd6de3c8af5dbc99b798 for python:3.6 ...
Running on runner-2exFJBTm-project-19-concurrent-0 via eec8077625c3...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/tools/xxxxxxx/.git/
Created fresh repository.
remote: You are not allowed to download code from this project.
fatal: unable to access 'https://git.example.com/tools/xxxxxxx.git/': The requested URL returned error: 403
ERROR: Job failed: exit code 1

问题原因

该问题的原因有很多,我们场景可能仅是其中的一种。

我们的原因是:因为我们是管理员用户,能访问仓库,但是不是仓库成员,所以不能拉取代码(但是我们却能在命令行拉取代码)。

解决方案

将当前用户(执行 Pipeline 用户)加入到该项目中,再次提交构建,此时可以成功构建。

参考文献

Runner can't pull code from server - GitLab CI/CD - GitLab Forum

;