CircleCI Ideas

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).

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Apr 2 2018
  • Shipped
  • Attach files
  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    5 Dec, 2019 07:22pm

    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 https://circleci.com/docs/2.0/pipeline-variables/#pipeline-values for more info.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    23 May, 2019 11:13am

    Any update on this?

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    22 Jan, 2019 11:14am

    Any idea when this will be implemented?

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    14 Jun, 2018 01:24pm

    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 :)

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    29 May, 2018 08:23am

    Furthermore, it would be great to be able to access all the build numbers and artifacts for a given workflow, e.g.


    https://circleci.com/workflow-run/<workflow_id>/builds

    https://circleci.com/workflow-run/<workflow_id>/artifacts/<path>

    or
    https://circleci.com/workflow-run/<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.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    2 Apr, 2018 05:25pm

    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.