allow empty workflow jobs

It would be useful to allow "empty" (need a better name) workflow steps with the following properties:

  • can take part in dependency chains, i.e.
    • can require other jobs to complete
    • can be required by other jobs to complete
  • no build steps and require no build agent to run (similar to "approval" jobs)

Such jobs could be useful in structuring and organising workflows.
They would save repetition allowing cleaner, DRYer workflow code
and the diagrams would be more unserstandable.

For example, imagine the following scenario:

  • 3 build steps which run in parallel
  • when all 3 succeed, you want 3 deploy steps to run in parallel

Currently you'd do it like this:

workflows:
version: 2.1
build_then_deploy:
jobs:
- build1
- build2
- build3
- deploy1:
requires:
- build1
- build2
- build3
- deploy2:
requires:
- build1
- build2
- build3
- deploy3:
requires:
- build1
- build2
- build3

 

The resultant, confusing diagram would look like this:

build1 --+-- deploy1
|
build2 --+-- deploy2
|
build3 --+-- deploy3

 

Adding an "empty" job would allow you to refactor, like this:

 

workflows:
version: 2.1
build_then_deploy:
jobs:
- build1
- build2
- build3
- builds_completed:
type: empty
requires:
- build1
- build2
- build3
- deploy1:
requires:
- builds_completed
- deploy2:
requires:
- builds_completed
- deploy3:
requires:
- builds_completed

The code is more natural to read and the diagram would be less confusing:

build1 --+                      +-- deploy1
| |
build2 --+-- builds_completed --+-- deploy2
| |
build3 --+ +-- deploy3
  • Guest
  • Feb 1 2019
  • Not planned
  • Attach files
  • Guest commented
    16 Jul 02:28

    A problem with the "trivial job that just echoes success" is that it has to spin up a vm to do that. The empty or no-op job would be a special job type understood by circleci where no vm needs to be spun up to interpret or run job steps. CircleCI servers under heavy load, can delay jobs by minutes, and spinning up a vm just to echo "success" to mimic this is a waste of resources. I've encountered this problem before, and like the original poster, I'd want to see a empty or no-op job type to help organize workflows. I suggest calling the work flow type "no-op".

    workflows:
    version: 2.1
    build_then_deploy:
    jobs:
    - build1
    - build2
    - build3
    - builds_completed:
    type: no-op
    requires:
    - build1
    - build2
    - build3
  • Nathan Dintenfass commented
    February 20, 2019 01:18

    It would be simple enough to add a "trivial" job that just echoes success to accomplish this. A longer-term solution might be to have other ways to add nodes to the workflow graph that aren't "jobs", but that's a ways out for us.