ื ืืชื ืืืืืืจ ืืฉืชื ืื ื-Gitlab ืืืกืคืจ ืืงืืืืช:
- ืืืืืจืืช ืืงืืืฆื
- ืืืืืจืืช ืืคืจืืืงื
- ืืชืื .gitlab-ci.yml
ืืืงืจื ืื, ื ืืชื ืืืืืืจ ืืฉืชื ืื ืืืืืจืืช ืืงืืืฆื ืืืคืจืืืงื ื"ืงืืืฅ" ืื "ืืฉืชื ื ืจืืื" ืืืกืื ืืช ืชืืืืช ืืกืืืื "ืืืื" ื"ืืกืื".
ื ืชืืื ืืืจืืฉื ืคืฉืืื ืืืื ืชืืคืื ืืืจืืืช ืืืชืจ ืืืืจืื.
ืืช ืืจืฉืืื ืืกืืคืืช ืฉื ืจืืืช ืืขืืืคืืช ื ืืชื ืืืฆืื ืืกืืฃ ืืืกืื.
ืืจืืฉื ืขื ืงืืืฆืืช [ืืงืืจืืช]
ืืฉืชื ืื ืืงืืืฆืืช ืขืืืจืื ืืืจืืฉื, ืืืฉืจ ืืืื ืฉืืื ืฉืืงืืืฆื ืืืืงืืช ืงืจืื ืืืชืจ ืืคืจืืืงื, ืื ืืขืจื ืฉืื ืืฉืื ืืืชืจ.
ืงืืืฆืืช ืขื ืืฉืชื ืื
.gitlab-ci.yml
image: busybox:latest
variables:
GIT_STRATEGY: none
echo:
stage: test
script:
- echo $MSG
ืชืืฆืืช ืฆืื ืืจ
$ echo $MSG
B
ืื ืืืฉืชื ื ืื ืืื ืืฆืืื ืืงืืืฆื B, ืื ืืืื ื ืจืืืื ืืช ืืขืจื A.
ืืืจืฉืช ืืฉืชื ืื ืืชืื .gitlab-ci.yml [ืืงืืจืืช]
ืืื ืื ืคืฉืื ืืื: ืืชื ืืืื ืืืืืืจ ืืฉืชื ื ืืืืืื, ืื ืฉืืชื ืืืื ืืืืืืฃ ืืืชื ืืชืื ืืขืืืื.
ืงืืืฆืืช ืขื ืืฉืชื ืื
.gitlab-ci.yml
ืืขืช ื ืืฆืืจ 2 ืืฉืจืืช, ืืืืช ืืื ื ืฆืืื ืืืคืืจืฉ $MSG.
image: busybox:latest
variables:
GIT_STRATEGY: none
MSG: "Custom in global .gitlab-ci.yml"
echo:
stage: test
script:
- echo $MSG
echo with var:
stage: test
variables:
MSG: "Custom in job .gitlab-ci.yml"
script:
- echo $MSG
ืชืืฆืืช ืฆืื ืืจ
- ืึตื:
$ echo $MSG Custom in global .gitlab-ci.yml Job succeeded
- ืื ืขื vars:
$ echo $MSG Custom in job .gitlab-ci.yml Job succeeded
ืืจืืฉื ืขื ืงืืืฆืืช ืืืชืื .gitlab-ci.yml [ืืงืืจืืช]
ืืืื ื ื ืกื ืืฉืื ืืช 2 ืืืืืืืืช ืืงืืืืืช. ืืฉืชื ื ืงืืืฆื ืืงืืืื ืขืืืคืืช ืขื ืืฉืชื ืื ืืชืื .gitlab-ci.yml.
ืงืืืฆืืช ืขื ืืฉืชื ืื
.gitlab-ci.yml
image: busybox:latest
variables:
GIT_STRATEGY: none
MSG: "Custom in global .gitlab-ci.yml"
echo:
stage: test
script:
- echo $MSG
echo with var:
stage: test
variables:
MSG: "Custom in job .gitlab-ci.yml"
script:
- echo $MSG
ืชืืฆืืช ืฆืื ืืจ
- ืึตื:
$ echo $MSG Y Job succeeded
- ืื ืขื vars:
$ echo $MSG Y Job succeeded
ืืจืืฉื ืขื ืฆืืื ืืฉืชื ืื ืืืืืจืืช ืืคืจืืืงื [ืืงืืจืืช]
ืืืฉืชื ืื ืืืืืจืืช ืืคืจืืืงื ืชืืื ืืฉ ืืช ืืขืืืคืืช ืืืืืื ืืืืชืจ! ืืืืฉืชื ืื ืืืฆืืื ืื ืืชืื .gitlab-ci.yml ืืื ื ืืืืืื ืฉืื ืชืคืงืื.
ืงืืืฆืืช ืขื ืืฉืชื ืื
ืืืฉืชื ืื ืงืืืฆืชืืื ืืฉ ืขืืืคืืช ื ืืืื ืืืชืจ.
.gitlab-ci.yml
ืืืื ื ืฉืชืืฉ ืืงืืืฅ ืืืืืืื ืืงืืืืช. ืืื ืฉืื ืืฉ ืืฉืชื ืื ืฉืฆืืื ื ืืชืื .gitlab-ci.yml, ืืื ืืฉืชื ืื ืืชืื ืงืืืฆืืช ืขืืืื ืืงืืืื ืขืืืคืืช ืขืืืื.
image: busybox:latest
variables:
GIT_STRATEGY: none
MSG: "Custom in global .gitlab-ci.yml"
echo:
stage: test
script:
- echo $MSG
echo with var:
stage: test
variables:
MSG: "Custom in job .gitlab-ci.yml"
script:
- echo $MSG
ืชืืฆืืช ืฆืื ืืจ
- ืึตื:
$ echo $MSG project-3 Job succeeded
- ืื ืขื vars:
$ echo $MSG project-3 Job succeeded
ืืจืืฉื ืขื ืขืจื ืจืืง [ืืงืืจืืช]
ืขืจื ืจืืง ืืื ืื ืขืจื
ืขืจื ืจืืง ืืื ื Null
ืงืืืฆืืช ืขื ืืฉืชื ืื
.gitlab-ci.yml
image: busybox:latest
variables:
GIT_STRATEGY: none
MSG: "Custom in global .gitlab-ci.yml"
echo:
stage: test
script:
- echo $MSG
echo with var:
stage: test
variables:
MSG: "Custom in job .gitlab-ci.yml"
script:
- echo $MSG
ืชืืฆืืช ืฆืื ืืจ
- ืึตื:
$ echo $MSG Job succeeded
- ืื ืขื vars:
$ echo $MSG Job succeeded
ืืจืืฉื ืขื include ืืงืืืฆืืช [ืืงืืจืืช]
ืืื ื ื ืกื ืืืืื ืืช ืคืจืืืงื-2 ืืคืจืืืงื-3
ืืงืืืฆืืช ืืืงืจื ืื ืืฉ ืขืืืคืืช.
ืงืืืฆืืช ืขื ืืฉืชื ืื
.gitlab-ci.yml
ืืืืืจ ืืช ืืืฉืชื ื ืืืืืื ื-.gitlab-ci.yml
variables:
MSG: "With include .gitlab-ci.yml"
include:
- project: how-is-gitlab-ci-inherit-environment-variables/z/y/project-3
file: '.gitlab-ci.yml'
ืชืืฆืืช ืฆืื ืืจ
- ืึตื:
$ echo $MSG B Job succeeded
- ืื ืขื vars:
$ echo $MSG B Job succeeded
ืืจืืฉื ืขื include [ืืงืืจืืช]
ืืื ื ื ืกื ืืืืื ืืช ืคืจืืืงื-2 ืืคืจืืืงื-3.
ืืชื ืื ืฉ: ืื ืืงืืืฆืืช ืืื ืืคืจืืืงื ืขืฆืื ืืฉ ืืฉืชื ืื.
ืงืืืฆืืช ืขื ืืฉืชื ืื
.gitlab-ci.yml
ืืืชื ืืืจ ืืื ืืืืืื ืืงืืืืช
variables:
MSG: "With include .gitlab-ci.yml"
include:
- project: how-is-gitlab-ci-inherit-environment-variables/z/y/project-3
file: '.gitlab-ci.yml'
ืชืืฆืืช ืฆืื ืืจ
- ืึตื:
$ echo $MSG With include .gitlab-ci.yml Job succeeded
- ืื ืขื vars:
$ echo $MSG Custom in job .gitlab-ci.yml Job succeeded
ืืชืืฆืืืช ืื ืืืืงืื ืกืืจื ืขืืืคืืืืช:
- ืืฉืชื ืื ืืืืืจืืช ืืคืจืืืงื
- ืืฉืชื ืื ืืงืืืฆืืช
- ืืฉืชื ืื ืฉืฆืืื ื ืืงืคืื ืืช ืืชืื ืขืืืืืช (ืืืื ืงืืฆืื ืืืืืื)
- ืืฉืชื ืื ืืืืืืืื ืืชืื .gitlab-ci.yml
- ืืฉืชื ืื ืืืืืืืื ืืชืื ืงืืฆืื ืืืืืื
ืืกืงื ื
ืื ืงืืื ืืื ืื ืืจืืจื ืืื ืฉืืืื "ืืื ืฉืืฉืชื ื ืงืจืื ืืืชืจ ืืงืื, ืื ืืื ืืฉืื ืืืชืจ" ืขืืื ืชืืืื ืขืืืจ ืงืืืฆืืช, ืืืืืจ ืืื ืืืชื ืืื ืขืืืจ ืืฉืชื ืื ืืชืื .gitlab-ci.yml, ืืื ืจืง ืืชื ืื ืฉืืืฉืชื ืื ืืงืืืฆืืช ืืื ื ืืฆืืื ืื.
ืืืืจ ืืื, ื ืงืืื ืืฉืืื ืืื ืืืืื ืฉืืืจืื ืืืืืืื ืขืืืจ .gitlab-ci.yml ืืจืืฉื ืืืืืื ืืื ื ืคืืฅ. ืืืงืืืฅ ืฉืื ืืชืจืืฉืช ืืืืืื ืืฉ ืขืืืคืืช.
ืืงืืจ: www.habr.com