I have created a Gitlab Pipeline. I want to use variable for which I can set the value dynamically.
e.g. I have created a variable with default value which will be used in each stage of the pipeline. But for Stage B I want to use different value for that variable. reference code as below.
jobA:
stage: A
allow_failure: true
script:
- echo "$LOG_PATH"
- echo "jobA" > ./completedA
artifacts:
paths:
- ./completedA
jobB:
stage: B
allow_failure: true
script:
- LOG_PATH="/opt/testlogs/"
- echo "${LOG_PATH}"
- exit 1
- echo "jobB" > ./completedB
artifacts:
paths:
- ./completedB
stages:
- A
- B
Variables:
LOG_PATH: "/opt/test/"
Current output for the variable:
For Stage A, Value of LOG_PATH is "/opt/test/"
For Stage B, Value of LOG_PATH is "/opt/test/"
Expected output for the variable:
For Stage A, Value of LOG_PATH is "/opt/test/"
For Stage B, Value of LOG_PATH is "/opt/testlogs/"