How I can get the gitlab-ci environment variable VERSION
value from the python script - get_version.py
for a gitlab-runners which will work on both OS windows and linux?
I need some universal solution so that it works on both OS.
Here is my .gitlab-ci.yml
:
stages:
- versioning
variables:
VERSION: ""
versioning:
stage: versioning
script:
- echo "[versioning] ..."
- python ./ci-cd_scripts/get_version.py
- echo $VERSION
Here is my ./ci-cd_scripts/get_version.py
:
import os
refName = os.environ.get("CI_COMMIT_REF_NAME")
piplineID = os.environ.get("CI_PIPELINE_ID")
relVersion = refName + ".0." + piplineID
version = relVersion.replace("rel.", "")
print("current version is", version)