patternpythonMinor
CI pipeline including upload to pypi repo
Viewed 0 times
pypiuploadincludingpipelinerepo
Problem
How should a ci pipeline be set up that publishes a python wheel to a private pypi server?
Say I have a publish job like this one:
With this approach I have a problem with my workflow: Imagine I create a feature branch where I do some changes. I push my changes, pipeline runs and eventually publishes the package to the pypi server. However, once I want to merge that MR it will trigger the pipeline once again and publishing will fail as one cannot reupload packages more than once to pypi.
This comes along with quite some problems so what I'm asking for is how other do things like that or what best practices are known for this scenario.
Feel also free to point me to another *overflow if this is not the right place for it.
Say I have a publish job like this one:
publish:
image: $PYTHON_IMAGE
stage: publish
before_script:
- poetry install
- poetry config repositories.nexus-pypi http://my-nexus.com/pypi-internal/
script:
- poetry build -f wheel
- poetry publish -r nexus-pypi -vvv -u $NEXUS_PYPI_USERNAME -p $NEXUS_PYPI_PASSWORDWith this approach I have a problem with my workflow: Imagine I create a feature branch where I do some changes. I push my changes, pipeline runs and eventually publishes the package to the pypi server. However, once I want to merge that MR it will trigger the pipeline once again and publishing will fail as one cannot reupload packages more than once to pypi.
This comes along with quite some problems so what I'm asking for is how other do things like that or what best practices are known for this scenario.
Feel also free to point me to another *overflow if this is not the right place for it.
Solution
You can use
e.g. set rules to only publish package when branch name is
You can even use regex for filtering branch name.
Hope it helps.
rules in gitlab ci to control when you want to stage to be executed: https://docs.gitlab.com/ee/ci/yaml/index.html#rulese.g. set rules to only publish package when branch name is
master.You can even use regex for filtering branch name.
Hope it helps.
Context
StackExchange DevOps Q#15396, answer score: 1
Revisions (0)
No revisions yet.