Publish a Generic Package via CI/CD returns 403
I’m trying to publish a generic package via API according to Docu: Publish a package file
Within the very same project I’m trying to publish a package via CI/CD to the Generic Package Registry.
To realize this I’m using a $CI_JOB_TOKEN, which is supposed to have write access to the same project at which the Pipeline is running (by default).
To do it like this is recommended by the Official Docu CI/CD Example and Example CI/CD Pipeline
On my side the request inside gitlab-ci.yml looks like the following pattern:
# Define beginning part of the URL
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE_NAME}/${CI_COMMIT_TAG}"
# Of course $CI_COMMIT_TAG matches
# package version regex \A(\.?[\w\+-]+\.?)+\z
# (like some can check at https://rubular.com/r/aNCV0wG5K14uq8)
# actual curl upload request
curl --fail -H "JOB-TOKEN: $CI_JOB_TOKEN" -T ./README.md -o /dev/null ${PACKAGE_REGISTRY_URL}/README.md
As a result I’m getting:
curl returns 403 Forbidden
curl: (22) The requested URL returned error: 403
What I expect to see:
The file uploads/package publishes successfully like it’s supposed to be.
Versions:
- GitLab: v16.5.0
- Runner: v16.5.0