'How to not trigger pipeline when creating a new branch from an existing branch in git?

I have a particular stage in my .gitlab-ci.yml file that I want to run when I push commit on some particular branch. But I don't want to run it when creating a new branch from an existing branch ( say master ). Is there any way to do it ? I tried checking it using ${CI_PIPELINE_SOURCE} environment variable. But it has the value "push" for both the times when pushing commits as well as creating a branch.



Solution 1:[1]

Assuming your "particular branch" has a specific name or even a specific pattern in naming, then you can make use of the only option.

As per one of the examples, you can even use regular expression to denote a pattern for the ref that it matches on:

only:
    - /^issue-.*$/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arty-chan