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…