Path-Filtering orb not triggering workflows

Hello,

I am experiencing issue with the path-filtering orb.

The default parameters for triggering a workflow are set to false in the continue_config, and in the config they are set to true, however the changes within the directories are not detected and the parameter doesn’t change its value to true.

I’ve tried correcting the mapping paths based on the exact directory that the code is located in the circleci istance that is being used during deploy but without success.

Weird part is I have another repo with 99% similar configuration that is working as expected.

I have created a separate branch from the one that I am working on so from feature/KI-10 to feature/KI-10-pipe-test just to make sure that it will do the base-revision based on the changes between the KI-10 and KI-10-pipe-test branch.

After that I’ve added some changes within the directory, however it’s not being picked up.

The configuration is below:

config.yml:

version: 2.1

setup: true

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

workflows:
  setup-workflow:
    jobs:
      - path-filtering/filter:
          base-revision: feature/KI-10-pipe-test
          config-path: .circleci/continue_config.yml
          mapping: |
            cloud-dev/01-route-53/.* trigger-cloud-dev-dir-01-route53 true

continue_config.yml:

version: 2.1

deploy_branch: &deploy_branch
  filters:
    branches:
      only: feature/KI-10

orbs:
  terraform: circleci/terraform@3.2.1

executors:
  base:
    docker:
      - image: ptccorp/image:latest
#-----------
# PARAMETERS
#-----------

###########################################
###Trigger Workflow Parameters Cloud-Dev###
###########################################
parameters:
  trigger-cloud-dev-dir-01-route53:
    type: boolean
    default: false

#########################################
###Directory Path Parameters Cloud-Dev###
#########################################

  cloud-dev-dir-path-01-route53:
    type: string
    default: /home/circleci/project/cloud-dev/01_route53


#-----------
# WORKFLOWS
#-----------
#########################
###Cloud-Dev Workflows###
#########################

workflows:
  cloud-dev-deploy-01-route53:
    when: 
      or: 
        - << pipeline.parameters.trigger-cloud-dev-dir-01-route53 >>
    jobs:
      - terraform/init:
          <<: *deploy_branch
          checkout: true
          path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
      - terraform/plan:
          <<: *deploy_branch
          checkout: true
          path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
          persist-workspace: true
          out: tf_plan_01_route_53
          requires:
            -  terraform/init
      - deploy-approval:
          <<: *deploy_branch
          name: 'Approval Gate AWS'
          type: approval
          requires:
            - terraform/plan

OK, I’m at my limits of my understanding of git and the path-filtering orb, but I do have one question

The line

          base-revision: feature/KI-10-pipe-test

Try changing the ‘/’ to a different character. ‘/’ is a valid character for naming a branch, but there is a lot of scripting going on in the ORB and there is a chance it is causing an unexpected outcome.

Hey @rit1010 and thank you for answering!

Unfortunately I don’t think this is the case, I tried with:
base-revision: pipe-test
however without success unfortunatelly.

For some reason it doesn’t detect changes and the parameter doesn’t changes to true so the workflow is not triggered, but I am struggling to understand why.

In the Set Up Parameters:

No change detected in the paths defined in the mapping parameter

In the Continue Pipeline:

{
  "continuation-key": "************************************************************************************************************************************************************************************************************************************************************************************************************************",
  "configuration": "{}\n",
  "parameters": {}
}
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   399  100    16  100   383     91   2182 --:--:-- --:--:-- --:--:--  2267
{"message":"OK"}

The current test was done with empty continue_config.yml and the following configuration:

version: 2.1

setup: true

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

workflows:
  setup-workflow:
    jobs:
      - path-filtering/filter:
          base-revision: pipe-test
          config-path: .circleci/continue_config.yml
          mapping: |
            cloud-dev/01-route-53/.* trigger-cloud-dev-dir-01-route53 true .circle/continue_config_cloud_dev.yml
            dev/01-route053/.* trigger-dev-dir-01-route53 true .circle/continue_config_dev.yml

Just did some more testing, it looks like the issue is related to the mapping itself.
I tried with the following mapping:

cloud-dev/.* trigger-cloud-dev-dir-01-route53 true

And it worked, however I want to trigger the workflow only when there are changes within cloud-dev/01_route53/.*

Any ideas?

To be honest, no as the usage example shows a sub-directory mapping just like the one you are having an issue with.

I see that you have already posted to the ORB’s github area which is about the only thing I had left to propose.

I think I found a solution

config.yml

version: 2.1

setup: true

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

workflows:
  setup-workflow:
    jobs:
      - path-filtering/filter:
          base-revision: pipe-test
          mapping: |
            cloud-dev/01_route53/.* trigger-cloud-dev-dir-01-route53 true .circleci/continue_config_cloud_dev.yml
            dev/01_route53/.* trigger-dev-dir-01-route53 true .circleci/continue_config_dev.yml

continue_config_cloud_dev.yml:

version: 2.1

deploy_branch: &deploy_branch
  filters:
    branches:
      only: feature/KI-10

orbs:
  terraform: circleci/terraform@3.2.1

executors:
  base:
    docker:
      - image: ptccorp/tf-aws:latest
#-----------
# PARAMETERS
#-----------

###########################################
###Trigger Workflow Parameters Cloud-Dev###
###########################################
parameters:
  trigger-cloud-dev-dir-01-route53:
    type: boolean
    default: false

#########################################
###Directory Path Parameters Cloud-Dev###
#########################################

  cloud-dev-dir-path-01-route53:
    type: string
    default: /root/project/cloud-dev/01_route53

#-----------
# WORKFLOWS
#-----------
#########################
###Cloud-Dev Workflows###
#########################

workflows:
  cloud-dev-deploy-01-route53:
    when: 
      or: 
        - << pipeline.parameters.trigger-cloud-dev-dir-01-route53 >>
    jobs:
      - terraform/init:
          <<: *deploy_branch
          checkout: true
          path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
      - terraform/plan:
          <<: *deploy_branch
          checkout: true
          path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
          persist-workspace: true
          out: tf_plan_01_route53
          requires:
            -  terraform/init
      - deploy-approval:
          <<: *deploy_branch
          name: 'Approval Gate AWS'
          type: approval
          requires:
            - terraform/plan
      # - terraform/apply:
      #     <<: *deploy_branch
      #     checkout: true
      #     path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
      #     attach-workspace: true
      #     plan: 'tf_plan_01_route53'
      #     requires:
      #     - Approval Gate AWS

It turns out also the default directory of the instance was changed from /home/circleci to /root I have no idea why as I was using the same image.

1 Like