---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/gl-pipelines.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/gl-pipelines.md
  - href: en/sourcecraft/operations/gl-pipelines.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
title: Using GitLab pipelines in the SourceCraft CI/CD
description: Follow this guide to set up and operate GitLab pipelines in SourceCraft CI/CD processes.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


# Using GitLab pipelines in the SourceCraft CI/CD

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

You can set up and view repository configurations in the SourceCraft interface under ![image](../../_assets/console-icons/gear.svg) **Repository settings** in the ![image](../../_assets/console-icons/nut-hex.svg) **Configurations** section. Learn more in [this article](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/configuration-edit.md).

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

<!-- source: en/_includes/sourcecraft/ci-cd/gl-pipelines-intro.md -->
[SourceCraft CI/CD](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md) workflows support [pipelines](https://docs.gitlab.com/ci/pipelines/) with [GitLab syntax](https://docs.gitlab.com/ci/yaml/).

This allows transferring projects from GitLab without any major CI/CD reconfiguration and reusing the extensive library of existing pipeline examples.
<!-- endsource: en/_includes/sourcecraft/ci-cd/gl-pipelines-intro.md -->

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

Only [cloud workers](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/workers.md#cloud-workers) support running GitHub Actions or GitLab pipelines in SourceCraft CI/CD.

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

For more information, see [GitLab pipelines in the SourceCraft CI/CD](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/gl-pipelines.md).

To use a GitLab pipeline in the SourceCraft CI/CD, do the following:
1. If you do not have a repository yet, [create](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/repo-create.md) one.
1. [Add](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/add-file-repo.md) the `.sourcecraft/.gitlab-ci.yaml` file with your GitLab pipeline contents to the repository `main` branch.

    <!-- source: en/_includes/sourcecraft/ci-cd/gl-pipeline-example.md -->
    {% cut "Example of a GitLab pipeilne, .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 %}

    Supported [GitLab pipeline syntax](https://docs.gitlab.com/ci/yaml/) elements:
    * [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), also for remote files in other repositories and on websites
    * [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 does not support these GitLab pipeline syntax elements:
    * [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: en/_includes/sourcecraft/ci-cd/gl-pipeline-example.md -->

1. Similarly, add `.sourcecraft/ci.yaml` to the `main` branch. To run a GitLab pipeline in the SourceCraft CI/CD, use a [cube](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#cubes) with `gitlab_workflow`, like this:

    <!-- source: en/_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
                # Path to the GitLab pipeline configuration file
                gitlab_workflow: .sourcecraft/.gitlab-ci.yaml
    ```
    <!-- endsource: en/_includes/sourcecraft/ci-cd/gl-pipeline-in-cube-example.md -->

    As you can see in the example, the CI process will automatically start after committing changes to the `main` branch.

1. Check the CI process:
    1. Under ![image](../../_assets/console-icons/terminal-line.svg) **CI/CD** on the repository page, go to ![image](../../_assets/console-icons/arrows-3-rotate-right.svg) **CI/CD**.
    1. Open a running workflow.

        The page that opens will display the workflow tasks, cubes (task steps), as well as statuses and execution results.
    1. In the bottom-right corner of the `run-gitlab-workflow` cube, click ![image](../../_assets/console-icons/file-text.svg).
    1. Wait for the workflow to complete.

#### Useful links {#see-also}

* [GitLab pipelines in the SourceCraft CI/CD](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/gl-pipelines.md)
* [Integration with GitHub Actions in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/gh-actions.md)
* [Using GitHub Actions in SourceCraft CI/CD](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/gh-actions.md)
* [Setting up CI/CD to deploy an application to Yandex Serverless Containers using GitHub Actions](https://sourcecraft.dev/portal/docs/en/sourcecraft/tutorials/ci-cd-sourcecraft-github-actions.md)
* [Continuous integration and continuous deployment in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md)
* [Service connections SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/service-connections.md)
