# Run jobs based on changes in directory

**URL:** <https://discuss.circleci.com/t/run-jobs-based-on-changes-in-directory/49741>\
**Category:** Build Environment\
**Tags:** circle-yml\
**Created:** [October 31, 2023, 11:12pm UTC](https://discuss.circleci.com/t/run-jobs-based-on-changes-in-directory/49741 "2023-10-31T23:12:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ark1117](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@ark1117](https://discuss.circleci.com/u/ark1117)\
**Post date:** [October 31, 2023, 11:12pm UTC](https://discuss.circleci.com/t/run-jobs-based-on-changes-in-directory/49741/1 "2023-10-31T23:12:10Z")

</div>

**I want to run specific jobs based on changes to a specific directory.**

I’ve used path-filtering: circleci/path-filtering@0.1.1 with config.yml and continue\_config.yml.

here is a sample of my config files!

```auto
version: 2.1

setup: true

orbs:
  path-filtering: circleci/path-filtering@0.1.1

workflows:
  check-file-updates:
    jobs:
      - path-filtering/filter:
          name: check-updated-files
          mapping: |
            Readme/. upload_to_readme "staging"
            Gateway/gateway.json upload_gateway_spec "qa"
          base-revision: main
          config-path: .circleci/continue_config.yml
          filters:
            branches:
              only: main

```

continue\_config.yml

```auto
version: 2.1

# CircleCI parameters to control which workflow to run
parameters:
  generate_services:
    type: boolean
    default: false
  upload_to_readme:
    type: string
    default: ""
  upload_gateway_spec:
    type: string
    default: ""
  upload_aws_lambda:
    type: string
    default: ""
  patch_generated_services:
    type: boolean
    default: false

jobs:
  # Job for Rdme upload
  upload-yaml:
    docker:
      - image: cimg/node:15.1
    resource_class: small
    steps:
      - checkout
      - restore_cache:
          key: v1-rdme-1
      ...
      # Rest of the job steps
      ...

  # Job for generating spec files
  generate-services:
    docker:
      - image: circleci/python:3.9-node
    resource_class: small
    steps:
      - checkout
      ...
      # Rest of the job steps
      ...

  # Job for uploading gateway spec to s3
  upload-gateway-spec:
    docker:
      - image: cimg/base:2022.01
    resource_class: small
    steps:
      - checkout
      ...
      # Rest of the job steps
      ...

  upload-aws-lambda:
    docker:
      - image: circleci/python:3.9-node
    resource_class: small
    steps:
      - checkout
      ...
      # Rest of the job steps
      ...

  check-week:
    docker:
      - image: circleci/python:3.9
    resource_class: small
    steps:
      ...
      # Rest of the job steps
      ...

workflows:
  upload-to-readme-staging:
    when:
      equal: ["staging", << pipeline.parameters.upload_to_readme >>]
    jobs:
      - upload-yaml:
          filters:
            branches:
              only: main

  upload-to-readme-prod:
    when:
      equal: ["prod", << pipeline.parameters.upload_to_readme >>]
    jobs:
      - upload-yaml:
          filters:
            branches:
              only: main

  generate-spec-files:
    when: << pipeline.parameters.generate_services >>
    jobs:
    - generate-services:
        filters:
          branches:
            only: main

  patch-generated-spec-files:
    when: << pipeline.parameters.patch_generated_services >>
    jobs:
      - generate-services:
          filters:
            branches:
              only: main

  upload-gateway-file-qa:
    when:
      equal: ["qa", << pipeline.parameters.upload_gateway_spec >>]
    jobs:
      - upload-gateway-spec:
          filters:
            branches:
              only: main

  upload-gateway-file-preprod:
    when:
      equal: ["preprod", << pipeline.parameters.upload_gateway_spec >>]
    jobs:
      - upload-gateway-spec:
          filters:
            branches:
              only: main

  upload-aws-lambda:
    when:
      or:
        - equal: ['qa', <<pipeline.parameters.upload_aws_lambda>>]
        - equal: ['preprod', <<pipeline.parameters.upload_aws_lambda>>]
    jobs:
      - upload-aws-lambda:
          filters:
            branches:
              only: main

  scheduled-generate-spec-files:
    triggers:
      - schedule:
          cron: "0 16 * * 2" # This represents 9 AM PST every Tuesday
          filters:
            branches:
              only: main
    jobs:
      - check-week:
          context: ScheduledJobContext
          filters:
            branches:
              only: main
      - generate-services:
          requires:
            - check-week
          filters:
            branches:
              only: main

```

I’m facing an issue while running jobs specific like generate\_services.  
when I set my generate\_services to true its showing me Unexpected argument(s): generate\_services

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [November 1, 2023, 9:47am UTC](https://discuss.circleci.com/t/run-jobs-based-on-changes-in-directory/49741/2 "2023-11-01T09:47:24Z")

</div>

The first thing you may need to look at is the version of path-filtering you are using. 0.1.1 is somewhat dated

> **[CircleCI Developer Hub - circleci/path-filtering](https://circleci.com/developer/orbs/orb/circleci/path-filtering)**
>
> Continue a pipeline based on paths of changed files. This can be useful in a monorepo setup where one may want to trigger different workflows based on which module(s) in the repo has changed. This orb does not support server at this time.

With a number of changes having taken place

> **[Releases · CircleCI-Public/path-filtering-orb](https://github.com/CircleCI-Public/path-filtering-orb/releases)**
>
> Contribute to CircleCI-Public/path-filtering-orb development by creating an account on GitHub.

One poorly documented feature of the continuation configuration feature is that any pipeline parameters defined in the setup configuration must also be declared in the continuation configuration as they are automatically passed. If not the error you are reporting is thrown. (It is not clear if your samples are actual running code or cut-down examples to just make the issue clearer).

> <https://github.com/CircleCI-Public/api-preview-docs/blob/master/docs/setup-workflows.md#limitations>

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [November 8, 2023, 9:48am UTC](https://discuss.circleci.com/t/run-jobs-based-on-changes-in-directory/49741/3 "2023-11-08T09:48:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rosie](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rosie/32/35395_2.png) [@rosie](https://discuss.circleci.com/u/rosie)\
**Post date:** [August 19, 2024, 10:49pm UTC](https://discuss.circleci.com/t/run-jobs-based-on-changes-in-directory/49741/4 "2024-08-19T22:49:52Z")

</div>


