Auth in Gitlab to the Gitlab hosted package repository does not work correctly
Description
When the following is run in a CI job on GL, a 400 is returned, indicating that Auth succeeded (the 400 is expected on successful auth)
- "curl -v --header \"JOB-TOKEN: ${CI_JOB_TOKEN}\" \"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi\""
Using the following to attempt to push a package results in a 401, when from what I can tell, it shouldn't
- poetry config repositories.gitlab "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi"
- poetry config http-basic.gitlab "gitlab-ci-token" "${CI_JOB_TOKEN}"
- poetry publish -r gitlab
Am I just doing something wrong?
Workarounds
The aim is to push a built python package into the GL registry. The work-around is to use Twine
Publish with Twine:
image: python:3.12
stage: Publish
needs:
- job: Discern New Version Tag
artifacts: true
- job: Build Package
artifacts: true
script:
- pip install twine
- export TWINE_PASSWORD=${CI_JOB_TOKEN}
- export TWINE_USERNAME=gitlab-ci-token
- python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
rules:
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE != "merge_request_event"
Poetry Installation Method
pip
Operating System
Debian [python 3.12 image]
Poetry Version
Poetry (version 1.8.3)
Poetry Configuration
n/a
Python Sysconfig
No response
Example pyproject.toml
No response
Poetry Runtime Logs
n/a
Am I just doing something wrong?
I guess you are not reading the docs, and you are not searching for duplicates.
Probably https://python-poetry.org/docs/cli#usage
Will give this a shot, thanks!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.