ashraf minhaj
ashraf minhaj

Reputation: 1193

CircleCI filter branch by prefix

I am making a CICD pipeline with circle-ci-terraform

My dev branch names are dev/feature_name etc. Instead of running workflows by directly writing the branch name I want to use the prefix dev/ so that the same workflow runs for all branches starting with dev. Any idea how I can achieve that?

Here's my current workflow -

workflows:
  dev_workflow:
    jobs:
      - build:
          filters:
            branches:
              only:
                  - dev/cicd-integration

I already tried dev/*, it does not work.

Upvotes: 1

Views: 1597

Answers (1)

yaningo
yaningo

Reputation: 523

CircleCI uses the Java variant of RegEx pattern matching (https://circleci.com/docs/workflows/#using-regular-expressions-to-filter-tags-and-branches).

So in your case, you need to specify the following RegEx pattern:

  filters:
    branches:
      only:
        - /^dev\/.*/

Upvotes: 4

Related Questions