You can make gitlab runner jobs with another job.
That means we can define jobs like a function in programming.
It's cool function, when we have very similar jobs repeatedly
Here's some examples.
When we have many servers to deploy, we wrote .gitlab-ci.yml file like this.
deploy1:
script:
# send local files to remote server
- rsync -artlp --ignore-existing --exclude-from='.rsyncignore' ./ "$USER"@"$SERVER1":"$RSYNC_TO_PATH"
deploy2:
script:
# send local files to remote server
- rsync -artlp --ignore-existing --exclude-from='.rsyncignore' ./ "$USER"@"$SERVER2":"$RSYNC_TO_PATH"
We can change upper setting jobs like below.
.deploy_script: &deploy_script
script:
# send local files to remote server
- rsync -artlp --ignore-existing --exclude-from='.rsyncignore' ./ "$USER"@"$SERVER":"$RSYNC_TO_PATH"
deploy1:
<<: *deploy_script
variables:
USER: user_id
SERVER: 10.10.10.10
RSYNC_TO_PATH: /var/www
deploy2:
<<: *deploy_script
variables:
USER: user_id
SERVER: 10.10.10.11
RSYNC_TO_PATH: /var/www
This settings make more efficient when we have many similar jobs.
Define functional jobs 'deploy_script', and use this job on another jobs.
'Develop > GitLab' 카테고리의 다른 글
.gitlab-ci.yml (0) | 2018.01.16 |
---|---|
GitLab Runner (0) | 2018.01.08 |
GitLab 간편 설치하기 (0) | 2018.01.08 |