I have a Python script named app.py
that has the value of the project ID,
project_id = "p007-999"
I hard code it inside the .gitlab-ci.yml
file provided below,
# list of enabled stages, the default should be built, test, publish
stages:
- build
- publish
before_script:
- export WE_PROJECT_ID="p007-999"
- docker login -u "$WELANCE_REGISTRY_USER" -p "$WELANCE_REGISTRY_TOKEN" registry.welance.com
build:
stage: build
services:
- docker:dind
variables:
DOCKER_HOST: docker:2375
script:
- echo $WE_PROJECT_ID
- cd templates && pwd && yarn install && yarn prod && cd ..
- docker build -t registry.welance.com/$WE_PROJECT_ID:$CI_COMMIT_REF_SLUG.$CI_COMMIT_SHA -f ./build/ci/Dockerfile .
I would like to automate this. I think the steps for that will be,
a. write the
project_id
value from the Python script to a shell scriptvariables.sh
.
b. In thebefore_script:
of the YML file, execute thevariables.sh
and read the value from there.
How do I achieve it correctly?