Getting raw files from repo using API with a CI_JOB_TOKEN returns "404 Project Not Found", in internal project
Summary
During a pipleine, I'm running a script which contains this line of code:
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/xxx/repository/files/file.txt/raw?ref=main"
But in the pipeline in receive an error "404 Project Not Found". Using a project access token or personal access token, there is no problem.
Steps to reproduce
- Create an internal repo A containing a file.txt at its root
- Create an internal repo B
- Give repo B access to repo A in Setting/CICD/Token Access
- Create a job in the
.gitlab-ci.ymland add the above mentioned curl script - Push the code and observe the pipeline
What is the current bug behavior?
In the pipeline, I get the following response:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 35 100 35 0 0 145 0 --:--:-- --:--:-- --:--:-- 145
{"message":"404 Project Not Found"}
What is the expected correct behavior?
Expecting the pipeline to return the contents of repo A/file.txt At the very least, if the CI_JOB_TOKEN does not cover access to repo A, it should return a 403 Forbidden error, rather than 404.
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Gitlab 16.10.x Running with gitlab-runner 15.8.2
Other info
This bug is similar to this one but with the CI_JOB_TOKEN instead or project access token (which works).
Be careful to call the curl script from a script file, because the colon breaks .gitlab-ci.yml
Edited by 🤖 GitLab Bot 🤖