48 lines
1.3 KiB
YAML
48 lines
1.3 KiB
YAML
#
|
|
# Variables can be used to for more dynamic behavior in jobs and scripts.
|
|
# For more information, see https://docs.gitlab.com/ee/ci/variables/README.html
|
|
#
|
|
|
|
stages:
|
|
- test
|
|
|
|
variables:
|
|
VAR1: "Variable 1 defined globally"
|
|
|
|
use-a-variable:
|
|
stage: test
|
|
script:
|
|
- echo "You can use variables in jobs."
|
|
- echo "The content of 'VAR1' is = $VAR1"
|
|
|
|
override-a-variable:
|
|
stage: test
|
|
variables:
|
|
VAR1: "Variable 1 was overriden in in the job."
|
|
script:
|
|
- echo "You can override global variables in jobs."
|
|
- echo "The content of 'VAR1' is = $VAR1"
|
|
|
|
define-a-new-variable:
|
|
stage: test
|
|
variables:
|
|
VAR2: "Variable 2 is new and defined in the job only."
|
|
script:
|
|
- echo "You can mix global variables with variables defined in jobs."
|
|
- echo "The content of 'VAR1' is = $VAR1"
|
|
- echo "The content of 'VAR2' is = $VAR2"
|
|
|
|
incorrect-variable-usage:
|
|
stage: test
|
|
script:
|
|
- echo "You can't use variables only defined in other jobs."
|
|
- echo "The content of 'VAR2' is = $VAR2"
|
|
|
|
predefined-variables:
|
|
stage: test
|
|
script:
|
|
- echo "Some variables are predefined by GitLab CI/CD, for example:"
|
|
- echo "The commit author's username is $GITLAB_USER_LOGIN"
|
|
- echo "The commit branch is $CI_COMMIT_BRANCH"
|
|
- echo "The project path is $CI_PROJECT_PATH"
|