CircleCI-Archived / api-preview-docs

In-progress docs about the pre-release preview of CircleCI API v2
72 stars 39 forks source link

Conditional Job Support #49

Open eddiewebb opened 4 years ago

eddiewebb commented 4 years ago

With current features we can use parameters to have conditional workflows and conditional steps

The latter (steps) gets a little ugly with the amount of nesting, but in the use case that I have an optional job I can work around this by redefining the entire workflow again, and include the extra job, but the permutations here could explode.

Use case - only publish asset when version is provided.

version: 2.1

parameters:
  publish_target:
    default: "" #empty values considered FALSEY
    type: string

workflows:
  basic:
    jobs:
      - sample_job:
          name: Build It
      - sample_job:
          name: Share It
          when: <<pipeline.parameters.publish_target>>