Add a build number for workflow runs (shared by all jobs in a workflow)

Concurrent deploys have been a problem for us when using workflows. E.g. I merge commits A and B in rapid succession and two deploy workflows run at the same time potentially failing if my deploy task can't handle concurrent runs or deploying an older revision than expected when the builds finish out of order.

A partial, and possibly easy to implement, solution to this would be if we had access to a build number shared across all jobs in the workflow so we could at least identify build order (currently CIRCLE_BUILD_NUM is set when a job starts so the deploy job for the workflow triggered by commit A might be higher than the number for the deploy job in the workflow triggered by commit B if any of A's preceding jobs are slow).

This would also allow us to easily tag releases with a workflow number which might prove to be more human friendly than a job number because it would increment less dramatically (we run ~12 jobs per workflow iteration).

  • Guest
  • Apr 2 2018
  • Shipped
  • Attach files
  • Nathan Dintenfass commented
    April 02, 2018 17:25

    We have plans along these lines. Not yet sure when you'll see the changes, but we agree that there should be a way to tie all the jobs together via an incrementing integer. 

  • Nick s commented
    May 29, 2018 08:23

    Furthermore, it would be great to be able to access all the build numbers and artifacts for a given workflow, e.g.<workflow_id>/builds<workflow_id>/artifacts/<path>

    or<workflow_id>/builds/buildjs/artifacts (if you want to namespace the artifacts)

    This will make it much easier to access builds and artifacts for a workflow. A particular use-case that we depend on is posting links to artifacts like screenshots, logs, etc. when our bots post build summary comments to Slack/Github/Zulip at the end of workflow runs.

  • Harry Adams commented
    June 14, 2018 13:24

    I understand this may cause problems with existing artifacts created using the CIRCLE_BUILD_NUM var in v1; but persisting the first build step number is a bit messy. 

    Just from the hip, maybe some sort of prefixing: e.g. `WORKFLOW_X'. It's not ideal, we'd just really like to see this added. We'll take anything incremental and human readable :)

  • Chris Taylor commented
    January 22, 2019 11:14

    Any idea when this will be implemented?

  • Chris Taylor commented
    May 23, 2019 11:13

    Any update on this?

  • Nathan Dintenfass commented
    December 05, 2019 19:22

    You can now refer to << pipeline.number >> in configuration, which will be the same for all workflows and all jobs within the configuration file. See for more info.