2

This question is very similar to: How can I have unique build numbers across branches with Jenkins & the Pipeline Multibranch Plugin

However what I want is not only a unique build numbers, but sequential.

Before moving to multibranch, I was creating a version number using <YYYY>.<MM>.<BuildNumber> which would produce versions like 2020.03.789. This would be used as the build description, and as the NuGet package version and which is created and pushed to a Nexus repo.

It's important that the version is sequential as when I create a release in our deployment system (Octopus) I want to to pick the highest package version (the latest) and not have to search for it.

I have found this blog post which describes the same problem with a solution, but I don't want to get into the realms of creating an external service and making http requests in the pipeline.

I feel like this is quite a standard requirement/strategy for building versioned packages and that there must be a way to achieve this with just Jenkins? Or am I thinking about this in the wrong way?

David Masters
  • 8,069
  • 2
  • 44
  • 75
  • Contrary to what you might think, this is an unusual requirement, as you won't know from your version number what branch was built. Anyway, you may consider using Consul or Redis to hold the real version number, incrementing it as you want. – MaratC Mar 17 '20 at 18:16
  • Hmm, well for feature branches (as in GitFlow) I append a NuGet pre-release tag to the version with the branch name i.e. `2020.03.567-beta-` but when building from a release branch I don't think the branch name is significant in the version? – David Masters Mar 17 '20 at 18:30
  • If so, I don't understand the need in global build id. `2020.03.1` would be the result of build #1 of the release branch, `2020.03.2` of build #2, etc. – MaratC Mar 18 '20 at 08:49
  • You can use external services like https://www.nextbuildnumber.net/ – bvamos Dec 16 '22 at 13:12

0 Answers0