Config.yml - build and deploy conditionals - Testing

Now have a configuration which works when parameters are “true” for both build and deploy.

This builds and deploys

parameters:
  run_workflow_build:
    type: boolean
    default: true
  run_workflow_deploy:
    type: boolean
    default: true

Prior topic: Config.yml conditional for build and deploying multiple environments

Then I sequentially changed run_workflow_deploy: to false (change) (result) This seems to work properly and none of the multiple environments deploy to cloudsmith.

and then run_workflow_build: to false (change) (result)
This does not seem to be working properly for some reason. There are not individual builds showing, but errors.

The next thing I tried testing was enabling one of the environment buster-armhf build=true
(result) This still seems to have ‘schema’ errors again, and buster-armhf build does not work properly.

The next thing I tried testing was enabling environment buster-armhf build=true and enabling buster-armhf deploy=true (result) The environment does not deploy and there are lots of schema errors.

How do I fix these problems?

Hi @rgleason,

You need to add a “fallback step” that handles the case where none of the conditions are met; for example: a simple echo.

Here’s what it’d be for the build-android-armhf job:

build-android-armhf:
    docker:
     - image: 'circleci/android:api-28-ndk'
    environment:
      - OCPN_TARGET: android-armhf
    steps:
      - when:
          condition: <<pipeline.parameters.run_workflow_build>>
          steps:
            - checkout
            - run: chmod a+x ci/*.sh
            - run: bash ci/circleci-build-android-armhf.sh
      - when:
          condition: << pipeline.parameters.run_workflow_deploy >>
          steps:
            - run: ci/cloudsmith-upload.sh
            - run: echo "deploying"

      - run: echo "None of the conditions are met"

Also, note that you can use the CircleCI CLI to validate your config.yml before attempting to run the build.

Let me know if this helps.