CircleCI filter branch by prefix

781 Views Asked by At

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.

1

There are 1 best solutions below

4
yaningo On BEST ANSWER

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\/.*/