Файл /.gitlab-ci.yml
:
stages:
- build
- test
- deploy
default:
image: alpine
build_a:
stage: build
script:
- echo "This job builds something."
build_b:
stage: build
script:
- echo "This job builds something else."
test_a:
stage: test
script:
- echo "This job tests something. It will only run when all jobs in the"
- echo "build stage are complete."
test_b:
stage: test
script:
- echo "This job tests something else. It will only run when all jobs in the"
- echo "build stage are complete too. It will start at about the same time as test_a."
deploy_a:
stage: deploy
script:
- echo "This job deploys something. It will only run when all jobs in the"
- echo "test stage complete."
environment: production
deploy_b:
stage: deploy
script:
- echo "This job deploys something else. It will only run when all jobs in the"
- echo "test stage complete. It will start at about the same time as deploy_a."
environment: production
Keywords | Значение |
---|---|
stages | Список основных стадий пайплайна |
default | Дефолтные параметры пайплайна |
variables | Переменные среды |
image | Docker образ для запуска |
rules | Правила исполнения запуска |
cache | Кеш, сохраняемый после задачи |
before_script | Действия перед исполнением скрипта |
script | Команды необходимые для исполнения задачи |
after_script | Действия после исполнения скрипта |
artifacts | Сохраняемые артефакты |
build-dev:
stage: build
script: echo "Feature branch, so building dev version..."
build-prod:
stage: build
script: echo "Default branch, so building prod version..."
test:
needs: ['build-dev']
interruptible: false
script: docker build -t my-image:$CI_COMMIT_REF_SLUG .
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
needs: ['build-prod']
changes:
- Dockerfile
when: manual
allow_failure: true
interruptible: true
variables:
IS_A_FEATURE: "true"
cache-job:
script:
- echo "This job uses a cache."
cache:
key: dependencies-cache-$CI_COMMIT_REF_SLUG
paths:
- .poetry