How to run pipelines on develop branch only

I was able to put the pipelines working, but right now I want to ignore some branches, best way would be to run the pipelines on develop branch only, here is my config.yml file:

version: 2.1
orbs:
  node: circleci/node@1.1.6
jobs:
  build:
    filters:
      branches:
        only:
          - develop
    executor:
      name: node/default
    steps:
      - checkout
      - node/with-cache:
          steps:
            - run: yarn install
            - run: yarn test
            - run: yarn build

However my config is failing, how do I do it?

UPDATE:
Here is the error CircleCi is showing in the result:

ERROR IN CONFIG FILE:

[#/jobs/build] 0 subschemas matched instead of one

1. [#/jobs/build] only 1 subschema matches out of 2

|   1. [#/jobs/build] extraneous key [filters] is not permitted

|   |   Permitted keys:

|   |     - description

|   |     - parallelism

|   |     - macos

|   |     - resource_class

|   |     - docker

|   |     - steps

|   |     - working_directory

|   |     - machine

|   |     - environment

|   |     - executor

|   |     - shell

|   |     - parameters

|   |   Passed keys:

|   |     - filters

|   |     - executor

|   |     - steps

2. [#/jobs/build] expected type: String, found: Mapping

|   Job may be a string reference to another job

Hello @valerxx22 - Welcome to our CircleCI Community!

You have the right approach here by using filters: for job branch. Could you share what error message or type of build failure you are encountering?

@JonathanC503 thanks for having a look at this, I have updated the description above with the error message, so that you can have a look.

Filters aren’t permitted on the definition of a job, you can use branch filters on the use of a job in a workflow - https://circleci.com/docs/2.0/configuration-reference/#workflows

E.g.:

workflows:
  build-and-test:
    jobs:
      - build:
          filters:
            branches:
              only:
                - develop

When a config only has a single job CircleCI will synthesize a workflow around it, but if you want to control what that workflow does you need to include it yourself.

-Gordon

1 Like

@gordon Great! This worked, thanks a lot!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.