I’m trying to fetch information about branches using this command inside a job:
curl -s --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API_URL/projects/$CI_PROJECT_ID/repository/commits/$CI_COMMIT_SHA/refs?type=all"
but it returns: {"message":"401 Unauthorized"}
Why is that? CI_JOB_TOKEN doesn’t have access to the project itself?
Hi,
Try putting JOB-TOKEN
instead of PRIVATE-TOKEN
to the header.
1 Like
No, it didn’t work. Looks like JOB-TOKEN
is not a thing.
But I accidentally figured out that $NPM_TOKEN
worked out. I.e.:
curl -s --header "PRIVATE-TOKEN: $NPM_TOKEN" "$GITLAB_API_URL/projects/$CI_PROJECT_ID/repository/commits/$CI_COMMIT_SHA/refs?type=all"
This is weird.
It works for me. Thank you
1 Like