# Workflow 2.0 - Filter for branch is not applied when running build

**URL:** <https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190>\
**Category:** Bug Reports\
**Created:** [February 5, 2019, 12:01pm UTC](https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190 "2019-02-05T12:01:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kkmiral](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kkmiral](https://discuss.circleci.com/u/kkmiral)\
**Post date:** [February 5, 2019, 12:01pm UTC](https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190/1 "2019-02-05T12:01:20Z")

</div>

Hello,

I have done integration of circleci with Github  
My config file looks as shown below. I wanted to restrict the circleci to build only if there are checkin to specific branch. But its not working as stated in workflow 2.0 docs.  
Please guide what is wrong in my config file.

* * *

```
version: 2
jobs:
  build:

    docker:
     - image: circleci/node:7.10

    steps:

      - run:
          command:
            export CF_USERNAME=$CF_USERNAME
            export CF_PASSWORD=$CF_PASSWORD
            export CF_API=$CF_API

      - checkout

      - restore_cache:
          key: dependency-cache-v2-{{ checksum "package.json" }}
      
      - run: npm install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: npm run build

      - setup_remote_docker:
          docker_layer_caching: true

workflows:
  version: 2
  run-for-cicd:
     jobs:
       - build:
            filters:
              branches:
                only: dev-circleci
```

---

<div class="post-metadata">

**Author:** ![kkmiral](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kkmiral](https://discuss.circleci.com/u/kkmiral)\
**Post date:** [February 5, 2019, 12:06pm UTC](https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190/2 "2019-02-05T12:06:19Z")

</div>

content of workflow from config file is not showing well formatted, but its all good in config file

---

<div class="post-metadata">

**Author:** ![KyleTryon](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kyletryon/32/9977_2.png) [@KyleTryon](https://discuss.circleci.com/u/KyleTryon)\
**Post date:** [February 7, 2019, 8:01pm UTC](https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190/4 "2019-02-07T20:01:20Z")

</div>

Hello @kkmiral,

How is this currently working your you? I ran a test of your config simplified.

```auto
version: 2
jobs:
  build:
    docker:
     - image: circleci/node:7.10
    steps:
      - run: echo "test commit to master with build job."

workflows:
  version: 2
  run-for-cicd:
     jobs:
       - build:
            filters:
              branches:
                only: dev-circleci

```

This will only execute a commit if the branch matches what you have listed.

---

<div class="post-metadata">

**Author:** ![kkmiral](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@kkmiral](https://discuss.circleci.com/u/kkmiral)\
**Post date:** [February 12, 2019, 9:42am UTC](https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190/5 "2019-02-12T09:42:21Z")

</div>

Hello @KyleTryon,

Currently, if i check in to other branch, say “master” then also it triggers the build job in circleci

I want that build trigger to happen only if it matches the branch name

---

<div class="post-metadata">

**Author:** ![florencia-caro](https://avatars.discourse-cdn.com/v4/letter/f/65b543/32.png) [@florencia-caro](https://discuss.circleci.com/u/florencia-caro)\
**Post date:** [September 4, 2019, 3:03pm UTC](https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190/6 "2019-09-04T15:03:20Z")

</div>

Hello. I would like to know if it is actually a bug and if so do you have an estimated date for the fix? In the company Im working we started migrating all our pipelines from Jenkins to CircleCi. But it feature is really necessary for us. We have the workflow branches filters in our config files but it is not working. Thanks.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [September 7, 2019, 6:47pm UTC](https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190/7 "2019-09-07T18:47:40Z")

</div>

> [@florencia-caro](#):
>
> I would like to know if it is actually a bug

Probably not - branch filtering has worked fine for me for the last couple of years. Do you have an example YAML file that is not working? If so, please post it here, using the formatting tools provided.

(If something is “not working” for you, the best kind of fault report is one that shows the problem - “me too” reports don’t help track problems down).

---

<div class="post-metadata">

**Author:** ![florencia-caro](https://avatars.discourse-cdn.com/v4/letter/f/65b543/32.png) [@florencia-caro](https://discuss.circleci.com/u/florencia-caro)\
**Post date:** [September 20, 2019, 12:00pm UTC](https://discuss.circleci.com/t/workflow-2-0-filter-for-branch-is-not-applied-when-running-build/28190/8 "2019-09-20T12:00:59Z")

</div>

The issue we were facing was exaclty the same that was posted before. Didn’t make sense to say the same. We fixed it. It was some character that was causing the yaml file breaks. We recreate the yaml file and it worked. Thanks!
