Reputation: 37
I want running the CMD: bash scripts/build.sh xxx in the parallel CI tasks, and xxx is the parameter, sometimes I want to trigger someone of the tasks by passing a variable SOURCE_PARAMETER equal to param_1 or param_2 or param_3, but it trigger failed, the .gitlab-ci.yml:
.template:
tags:
- xxx_cicd_test
allow_failure: false
script:
- echo "SOURCE_PARAMETER:$SOURCE_PARAMETER"
- bash scripts/build.sh $CLASSIFICATION
myjob:
extends: .template
parallel:
matrix:
- CLASSIFICATION: "param_1"
- CLASSIFICATION: "param_2"
- CLASSIFICATION: "param_3"
rules:
- if: $SOURCE_PARAMETER == "$CLASSIFICATION"
It seems that in section "rules" there is no access permission to the varabile CLASSIFICATION, what shall i do?
Upvotes: 0
Views: 38
Reputation: 37
I've fixed this issue: Move the rules from job myjob to .template, because SOURCE_PARAMETER and CLASSIFICATION are outside variable for .template:
.template:
tags:
- xxx_cicd_test
allow_failure: false
script:
- echo "SOURCE_PARAMETER:$SOURCE_PARAMETER"
- bash scripts/build.sh $CLASSIFICATION
rules:
- if: $SOURCE_PARAMETER == "$CLASSIFICATION"
myjob:
extends: .template
parallel:
matrix:
- CLASSIFICATION: "param_1"
- CLASSIFICATION: "param_2"
- CLASSIFICATION: "param_3"
Upvotes: 1