---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/gl-pipelines.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/concepts/gl-pipelines.md
  - href: ru/sourcecraft/concepts/gl-pipelines.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
title: Пайплайны GitLab в CI/CD SourceCraft
description: Как использовать пайплайны GitLab в CI/CD-процессах SourceCraft для автоматизации сборки и тестирования.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/ru/llms.txt


# Пайплайны GitLab в CI/CD SourceCraft

<!-- source: ru/_includes/sourcecraft/ci-cd/gl-pipelines-intro.md -->
В [CI/CD](https://sourcecraft.dev/portal/docs/ru/sourcecraft/concepts/ci-cd.md)-процессах SourceCraft поддерживается запуск [пайплайнов](https://docs.gitlab.com/ci/pipelines/) с [синтаксисом GitLab](https://docs.gitlab.com/ci/yaml/).

Функциональность позволяет переносить проекты из GitLab без существенной переработки конфигурации CI/CD, а также переиспользовать большую библиотеку существующих примеров пайплайнов.
<!-- endsource: ru/_includes/sourcecraft/ci-cd/gl-pipelines-intro.md -->

<!-- source: ru/_includes/sourcecraft/ci-cd/gh-gl-cloud-workers.md -->
{% note warning %}

Запуск GitHub Actions и пайплайнов GitLab в CI/CD SourceCraft поддерживается только на [облачных воркерах](https://sourcecraft.dev/portal/docs/ru/sourcecraft/concepts/workers.md#cloud-workers).

{% endnote %}
<!-- endsource: ru/_includes/sourcecraft/ci-cd/gh-gl-cloud-workers.md -->

Пайплайн GitLab встраивается в конфигурацию CI/CD `.sourcecraft/ci.yaml` в виде отдельного [кубика](https://sourcecraft.dev/portal/docs/ru/sourcecraft/concepts/ci-cd.md#cubes) с параметром `gitlab_workflow`, например:

<!-- source: ru/_includes/sourcecraft/ci-cd/gl-pipeline-in-cube-example.md -->
```yaml
on:
  push:
    - workflows: [sample-workflow]
      filter:
        branches: ["main"]

workflows:
  sample-workflow:
    tasks:
      - name: demo-gitlab-ci
        cubes:
          - name: run-gitlab-workflow
            # Путь к файлу с конфигурацией пайплайна GitLab
            gitlab_workflow: .sourcecraft/.gitlab-ci.yaml
```
<!-- endsource: ru/_includes/sourcecraft/ci-cd/gl-pipeline-in-cube-example.md -->

<!-- source: ru/_includes/sourcecraft/ci-cd/gl-pipeline-example.md -->
{% cut "Пример пайплайна GitLab .gilab-ci.yaml" %}

```yaml
build-job:
  stage: build
  script:
    - echo "Hello, GitLab CI/CD!"

test-job1:
  stage: test
  script:
    - echo "This job tests something"

test-job2:
  stage: test
  script:
    - echo "This job tests something, but takes more time than test-job1."
    - echo "After the echo commands complete, it runs the sleep command for 20 seconds"
    - echo "which simulates a test that runs 20 seconds longer than test-job1"
    - sleep 20

deploy-prod:
  stage: deploy
  script:
    - echo "This job deploys something."
```

{% endcut %}

Поддерживаются следующие элементы [синтаксиса пайплайнов GitLab](https://docs.gitlab.com/ci/yaml/):
* [after_script](https://docs.gitlab.com/ci/yaml/#after_script)
* [artifacts](https://docs.gitlab.com/ci/yaml/#artifacts)
* [before_script](https://docs.gitlab.com/ci/yaml/#before_script)
* [image](https://docs.gitlab.com/ci/yaml/#image)
* [include](https://docs.gitlab.com/ci/yaml/#include) (включая удаленные файлы в других репозиториях и на сайтах)
* [needs](https://docs.gitlab.com/ci/yaml/#needs)
* [rules](https://docs.gitlab.com/ci/yaml/#rules)
* [script](https://docs.gitlab.com/ci/yaml/#script)
* [services](https://docs.gitlab.com/ci/yaml/#services)
* [stage](https://docs.gitlab.com/ci/yaml/#stage)
* [stages](https://docs.gitlab.com/ci/yaml/#stages)
* [variables](https://docs.gitlab.com/ci/yaml/#job-variables)

{% note alert %}

В SourceCraft не поддерживаются следующие элементы синтаксиса пайплайнов GitLab:
* [environment](https://docs.gitlab.com/ci/yaml/#environment)
* [pages](https://docs.gitlab.com/ci/yaml/#pages)
* [release](https://docs.gitlab.com/ci/yaml/#release)
* [resource_group](https://docs.gitlab.com/ci/yaml/#resource_group)
* [trigger](https://docs.gitlab.com/ci/yaml/#trigger)

{% endnote %}
<!-- endsource: ru/_includes/sourcecraft/ci-cd/gl-pipeline-example.md -->

<!-- source: ru/_includes/sourcecraft/configuration-tip.md -->
{% note tip %}

Настройка и просмотр конфигураций репозитория доступны в интерфейсе SourceCraft в разделе ![image](../../_assets/console-icons/gear.svg) **Настройки репозитория** в секции ![image](../../_assets/console-icons/nut-hex.svg) **Конфигурации**. Подробнее в инструкции [Настроить конфигурации репозитория в виде кода](https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/configuration-edit.md).

{% endnote %}
<!-- endsource: ru/_includes/sourcecraft/configuration-tip.md -->

#### Полезные ссылки {#see-also}

* [Использовать пайплайны GitLab в CI/CD SourceCraft](https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/gl-pipelines.md)
* [Интеграция с GitHub Actions в SourceCraft](https://sourcecraft.dev/portal/docs/ru/sourcecraft/concepts/gh-actions.md)
* [Использовать GitHub Actions в CI/CD SourceCraft](https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/gh-actions.md)
* [Настройка CI/CD для развертывания приложения в Yandex Serverless Containers с помощью GitHub Actions](https://sourcecraft.dev/portal/docs/ru/sourcecraft/tutorials/ci-cd-sourcecraft-github-actions.md)
* [Непрерывная интеграция и непрерывное развертывание в SourceCraft](https://sourcecraft.dev/portal/docs/ru/sourcecraft/concepts/ci-cd.md)
* [Сервисные подключения SourceCraft](https://sourcecraft.dev/portal/docs/ru/sourcecraft/concepts/service-connections.md)