Branch Unique Build Number?

In Jenkins you get a unique build number/history for each branch.
So master could be on build 20, I create a branch called foo, foo is on build 1
Is there any way of configuring this?

I seem to recall that workflows get a number - but it is an overall one, not per branch. This is available in an env var.

I am not sure there is out-of-the-box support for per-branch numbering, but you could use a flat-file database and cache it somewhere to associate a “next build number” to each branch.

Would you be able to share with us why you are attempting to replicate this behavior? If we have the use case you are trying to solve for we may be able to provide an alternate solution or at least document the request with the use-case.

When using workflows, each job increments the build number.
If I then have branches and each one of those doing 4-5 increments on the build number it becomes huge.

I tag my docker images with the build number so I can keep track of where I am at on deployments. You choose the branch then the build number.

Here is an example. Lets say I have (master, build 10), this my tenth master build.
After making some branches, (master, build 232) might be my 100th master build.

I’ve actually switched away from workflows completely and made everything a single job just so I don’t have to deal with the build number issue.

Honestly all I’d want is a single number for each unique workflow in each unique branch.
So each workflow for master goes 1, 2, 3, 4 etc.
Then each workflow for feature-branch goes 1, 2, 3, 4…

We are running into this same issue. We use the build count for each branch to tag each docker container that gets built for a specific release branch.

It does not appear that there is a way to even use the CircleCI API to get a list of all builds for a particular branch, which we could then determine the length of the response and use that to get the build number. It seems like your API responses do not include the record count with the response so we would have to set the limit to the max (100) to find out how many records match. There is no way to filter based on branch anyway.

The only way I can think this might be possible would be to have a workflow apply a git tag if successful based on a previous tag number and increment. Then have a container workflow run on tags only which would build the container.

Not ideal due to having to build assets that are contained in Docker all over again… but I don’t see any other way based on build parameters that are currently supported.