Using GitLab pipelines in the SourceCraft CI/CD

SourceCraft CI/CD workflows support pipelines with GitLab syntax.

This allows transferring projects from GitLab without any major CI/CD reconfiguration and reusing the extensive library of existing pipeline examples.

For more information, see GitLab pipelines in the SourceCraft CI/CD.

To use a GitLab pipeline in the SourceCraft CI/CD, do the following:

  1. If you do not have a repository yet, create one.

  2. Add the .sourcecraft/.gitlab-ci.yaml file with your GitLab pipeline contents to the repository main branch.

    Example of a GitLab pipeilne, .gilab-ci.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."
    

    Supported GitLab pipeline syntax elements:

    Alert

    SourceCraft does not support these GitLab pipeline syntax elements:

  3. Similarly, add .sourcecraft/ci.yaml to the main branch. To run a GitLab pipeline in the SourceCraft CI/CD, use a cube with gitlab_workflow, like this:

    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
    

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

  4. Check the CI process:

    1. Under CI/CD on the repository page, go to CI/CD.

    2. Open a running workflow.

      The page that opens will display the workflow tasks, cubes (task steps), as well as statuses and execution results.

    3. In the bottom-right corner of the run-gitlab-workflow cube, click .

    4. Wait for the workflow to complete.

See also