Pipeline.parameters in steps when conditions seems to have no value using dynamic configuration

Hello everyone,

I just read the documentation of dynamic configuration and I tried it with this config :

config.yaml

version: 2.1

# this allows you to use CircleCI's dynamic configuration feature
setup: true

# the path-filtering orb is required to continue a pipeline based on
# the path of an updated fileset
orbs:
  path-filtering: circleci/path-filtering@0.1.1

parameters:
  run-build-client-job:
    type: boolean
    default: false
  run-build-server-job:
    type: boolean
    default: false

jobs:
  check_commit_message:
    docker:
      - image: alpine/git:2.36.3
    steps:
      - checkout
      - run:
          name: Check commit message for [skip circleci]
          command: |
            if git log -1 --pretty=%B | grep -q -F '[skip circleci]'; then
              echo "CircleCI will NOT run the jobs"
              exit 1
            else
              echo "CircleCI will run the jobs"
              circleci-agent step halt
            fi

workflows:
  # the always-run workflow is always triggered, regardless of the pipeline parameters.
  always-run:
    jobs:
      - check_commit_message
      # the path-filtering/filter job determines which pipeline
      # parameters to update.
      - path-filtering/filter:
          name: check-updated-files
          # 3-column, whitespace-delimited mapping. One mapping per
          # line:
          # <regex path-to-test> <parameter-to-set> <value-of-pipeline-parameter>
          mapping: |
            client/.* run-build-client-job true
            server/.* run-build-server-job true
          base-revision: main
          # this is the path of the configuration we should trigger once
          # path filtering and pipeline parameter value updates are
          # complete. In this case, we are using the parent dynamic
          # configuration itself.
          config-path: .circleci/continue_config.yml

continue_config.yml

version: 2.1

orbs:
  codecov: codecov/codecov@3.2.4

parameters:
  run-build-client-job:
    type: boolean
    default: false
  run-build-server-job:
    type: boolean
    default: false

jobs:
  code-quality-server:
    docker:
      - image: cimg/php:8.2.12-browsers
    resource_class: large
    steps:
      - when:
          condition: << pipeline.parameters.run-build-server-job >>
          steps:
            - checkout
            - run: sudo echo 'memory_limit = 256M' | sudo tee -a /usr/local/etc/php/conf.d/docker-php-memlimit.ini
            - run: *server-dependencies

            - restore_cache: *restore_cache-server-deps-php
            - restore_cache: *restore_cache-server-deps-node

            - restore_cache:
                key: server-build-<< pipeline.id >>

            - run: make -C server lint.js

            - run: make -C server lint.php-cs-fixer@integration

            - run: make -C server lint.phpstan@integration


etc

With this I have the error
ERROR IN CONFIG FILE: [#/jobs/code-quality-server] only 1 subschema matches out of 2 1. [#/jobs/code-quality-server/steps] expected minimum item count: 1, found: 0 | SCHEMA: | minItems: 1 | INPUT: | null

And It comes from condition: << pipeline.parameters.run-build-server-job >> when i don’t make changes in the server folder and i don’t know why. It should just have pass the job

Thank you per advance for your help

Firstly, I’m not sure that the structure of your condition statement line will do what you expect. It expresses no logic condition, so the condition will always be considered true. You need to include an OR: in the layout - see the following example.

Secondly, CircleCI’s schema processing has an odd error that can cause what you are seeing.

It is best if I use a basic example, the code below is designed around job level parameters, rather than pipeline parameters, but the issue will likely be the same.

version: 2.1

jobs:
  build:
    parameters:
      run-build-server-job:
        type: boolean
        default: true
    docker:
      - image: cimg/php:8.2.12-browsers
    resource_class: large
    steps:
      - run: echo "one random action"
      - when:
          condition: 
             or: 
                - << parameters.run-build-server-job >>
          steps:
            - checkout
      
workflows:
  build-and-test:
    jobs:
      - build

The above workflow will run, if you edit the script and remove the line

- run: echo "one random action"

It will fail with the schema error you are seeing. So you should try adding such a line to your script.

Also as written the above script will not execute the checkout step as the condition returns false. It will execute the step if the default value of run-build-server-job is changed to true.

Thank you, you save my day. I just add - run echo “one random action” before the “when” and it work it seems that circle ci need at least one action he can despite the conditions after