I have a pipelines that publishes a python package to a private PYPI.
The below code works perfectly:
pipelines:
branches:
development:
- step:
runs-on:
- 'self.hosted'
- 'linux'
name: Bump version
deployment: Test
services:
- docker
caches:
- docker
script:
# bump package version
- echo "__version__ = '1.0.${BITBUCKET_BUILD_NUMBER}'" > gateway/version.py
- echo "__version__ = '1.0.${BITBUCKET_BUILD_NUMBER}'"
# See more details https://bitbucket.org/atlassian/pypi-publish/src/master
- pipe: atlassian/pypi-publish:0.3.1
variables:
PYPI_USERNAME: $pypi_username
PYPI_PASSWORD: $pypi_password
REPOSITORY: $pypiRepo
It basically changes the version on the version.py files and publishes to PyPI via a pipe.
However, if I want to put the pipe part on a step (because it will be done both from master and development branch, but with diffrent steps before publishing) I see that the changes are not persisted:
definitions:
steps:
- step: &publish
runs-on:
- 'self.hosted'
- 'linux'
services:
- docker
caches:
- docker
name: Publish to private PyPI
script:
# See more details https://bitbucket.org/atlassian/pypi-publish/src/master
- pipe: atlassian/pypi-publish:0.3.1
variables:
PYPI_USERNAME: $pypi_username
PYPI_PASSWORD: $pypi_password
REPOSITORY: $pypiRepo
- step: &getdependencies
name: Download project dependencies from PyPI
script:
- python3 -m pip download -r requirements.txt -d dist/
pipelines:
branches:
development:
- step:
runs-on:
- 'self.hosted'
- 'linux'
name: Bump version
deployment: Test
services:
- docker
caches:
- docker
script:
# bump package version
- echo "__version__ = '1.0.${BITBUCKET_BUILD_NUMBER}'" > gateway/version.py
- echo "__version__ = '1.0.${BITBUCKET_BUILD_NUMBER}'"
-step: *publish
I have come to this conclusion because version.py by default has version 1.0.0 (This is the one that is on the repository by default, before changing anything). If the pipe runs well the version pushed to PyPI ends up being 1.0.100 (for example, I am at build number 109 to be precise). But instead in the second yml the package published has version 1.0.0 (the "default" one)
Am I doing something wrong?
This is to be expected? If so, is there any workaround?