I have set my an environmental variable in my setup.py script and I would like to access this in my Pipelines script.
os.environ["MY_PKG_VERSION"] = str(version)
The thing is every time I echo this in my Pipelines script
- echo $MY_PKG_VERSION
nothing shows up. I tried creating an unsecured environmental variable in Pipelines (Settings->Pipelines->Environmental Variables) and accessed it via Python to update it, but this doesn't update it despite it working locally.
import os
import re
# Update the current version to the new version
current_version = os.environ['MY_PKG_VERSION']
release_version = int(re.sub(".\d+$", "", current_version))
patch_version = int(re.sub("^\d+.", "", current_version))
new_patch_version = patch_version + 1
new_version = "%d.%d" % (release_version, new_patch_version)
# Set version number as environmental variable
os.environ['MY_PKG_VERSION'] = new_version
print(current_version)
print(new_version)If $MY_PKG_VERSION is set to 0.1, then current_verision==0.1 and new_version==0.2. This script is run via Pipelines without failing and the print() outputs are displaying the correct values.
Ideally, I would be able to use the environmental variable set in my Python code within the Pipelines script by concatenating it to another string.
Any ideas on how to go about achieving this?
Cheers,
Grant