Problem to solve
I am trying to download a file from a private repository in the gitlab CI from another private repository.
When I set my gitlab-ci (example in Configuration), I get the error:
$ curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --output test.txt "${CI_API_V4_URL}/projects/$PROJECT_ID"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 35 100 35 0 0 149 0 --:--:-- --:--:-- --:--:-- 149
$ cat test.txt
{"message":"404 Project Not Found"}
Steps to reproduce
Create two repositories (A wants to access a file in B) in a private group.
Add the group of A to the allowlist of B in Settings
→ CI/CD
→ Job token permissions
→ its not possible to set A in the allowlist, only the group where A is in, as I can not find the project in the group.
Configuration
.gitlab-ci.yml
build-image:
stage: build
variables:
PROJECT_ID: <correct_project_id>
services:
- docker:20.10.23-dind
script:
- apk add --no-cache curl
- echo ${CI_API_V4_URL}
- >
curl --header "JOB-TOKEN: $CI_JOB_TOKEN"
--output test.txt
"${CI_API_V4_URL}/projects/$PROJECT_ID"
- cat test.txt
Versions
- Self-managed
- GitLab.com SaaS → Free Tier!
- Self-hosted Runners
Versions
- GitLab: 17.3
- GitLab Runner: Hosted on AWS EC2, 17.3, Git branch: 17-3-stable