Advanced Logic in Config

I’m happy to announce the recent addition of advanced
config-compile-time logic statements to config version 2.1. This is
part of our initiative to give users greater control over the work to
perform.

With logic statements you can combine literal values, pipeline values,
and pipeline parameters in various ways to produce arguments for when
stanzas in workflows and when steps.

A brief example:

my-job:
  steps:
    when:
      condition:
        or:
          - << pipeline.parameters.run-deploy >>
          - equal: [ master, << pipeline.git.branch >> ]
      steps:
        - run: ./deploy

This step will run on master, or if you specify the run-deploy
pipeline parameter via the API to trigger a manual deployment.

Head to the documentation or the configuration cookbook for more
details and examples.

7 Likes

This is a game changer

Just wonder if its possible to get something like this working

my-job:
  steps:
    when:
      condition:
        or:
          - condition_1
      steps:
        - run: ./deploy
    when:
      condition:
        or:
          - another condition
      steps:
        - run: ./deploy_2

Something of that logic,

Just to give some context, my comment comes from using this Orb CircleCI Developer Hub - circleci/path-filtering

So if no changes were detected, would be good to still return a success message - especially if you have github checks dependant on it