I am using a variable to define the ROOT_DIR in my .gitlab-ci.yml
variables:
ROOT_DIR: "/builds/company/projects/projectname/"
in the job I call the test.py function:
ut-job:
stage: test
script:
- echo "Unit testing ..."
- python3 tests/test_file.py "$ROOT_DIR"
In the test_file.py I call the command line inout as follows:
if __name__ == "__main__":
if sys.platform == "Darwin" or sys.platform == "Windows":
load_dotenv()
ROOT_DIR = os.getenv("ROOT_DIR")
else:
ROOT_DIR=sys.argv[1]
print("PLatform: " + sys.platform)
print("ROOT_DIR: " + ROOT_DIR)
unittest.main()
The printstatement in the pipeline output correctly prints the ROOT_DIR, so the sys.argv gets the variable correctly.
However, the pipeline fails with
AttributeError: module '__main__' has no attribute '/builds/company/projects/projectname/'
Meaning, the test_file.py main gets the Variable but somehow tries to use it also as an attribute.
Can somebody hint me what I did wrong?