How do I use the skip section in a pipeline as code?

Modified on Wed, 21 Jun 2023 at 02:56 PM

To use the skip section in a GitLab pipeline as code, you can define a step that will be skipped in the pipeline based on certain conditions. This can be useful when you want to exclude specific stages or jobs from running under specific circumstances.

Here's an example of how you can use the skip section:

  - build
  - test

  stage: build
    - echo "Building..."

  stage: test
    - echo "Running tests..."
    - if: '$CI_COMMIT_REF_NAME == "feature"'
      skip: true

In the above example:

The pipeline consists of two stages: build and test.

The build stage simply echoes "Building..." as an example.

The test stage runs tests using the script keyword.

The rules section is used to define a condition for the test stage.

The if condition checks if the current branch is named feature.

If the condition is met, the skip section is triggered with a value of true.

As a result, the test stage will be skipped when the branch is feature.

By using the skip section, you can control the execution of stages or jobs in your pipeline based on specific conditions. This allows you to customize the pipeline flow and exclude certain steps when necessary.

If you have further questions or need assistance with implementing the skip section or optimizing your pipelines, feel free to reach out to Cloud-Runner. We specialize in helping developers maximize the efficiency and performance of their CI/CD workflows. Visit to learn more about our services and how we can support your pipeline automation needs.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article