Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth in Gitlab to the Gitlab hosted package repository does not work correctly #9694

Closed
geudrik opened this issue Sep 18, 2024 · 2 comments
Closed
Labels
area/auth Related to the authenticator and keyring area/publishing Related to PyPI/PEP 503 publishing kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@geudrik
Copy link

geudrik commented Sep 18, 2024

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
@geudrik geudrik added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 18, 2024
@dimbleby
Copy link
Contributor

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

@geudrik
Copy link
Author

geudrik commented Sep 19, 2024

Will give this a shot, thanks!

@Secrus Secrus added area/publishing Related to PyPI/PEP 503 publishing area/auth Related to the authenticator and keyring labels Oct 13, 2024
@geudrik geudrik closed this as completed Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/auth Related to the authenticator and keyring area/publishing Related to PyPI/PEP 503 publishing kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants