Search code examples
continuous-integrationcirclecicicdcircleci-workflows

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.


Solution

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