Hi,
I'm using semantic versioning in the format of [major].[minor].[build_number] when building artifacts using bitbucket pipeline.
When moving from one minor version to another (e.g. from 1.0.xx to 1.1.xx), I would like to reset the build number to start again from 0.
Unfortunately, there is no way to reset build number - any ideas how to achieve my goal with bitbucket pipeline?
Hello @Motty Cohen and welcome to the community!
A workaround I can think of is to create a custom repository variable to track the build number value.
For example, you could create a repo variable (Repository Settings > Repository Variables) named $MY_BUILD_NUMBER that starts with the value 0.
For each build where you are not changing the minor version, you can use the value from that variable to create your version [major].[minor].[$MY_BUILD_NUMBER], and then from within the same build you can update the value of the repo variable $MY_BUILD_NUMBER to +1 by making a call to the endpoint Update a variable for a repository. Subsequent builds will get the updated value of the MY_BUILD_NUMBER.
curl -X PUT -u BBUSERNAME:BB_APPPASSWORD https://api.bitbucket.org/2.0/repositories/WORKSPACE/REPOSITORY/pipelines_config/variables/<VARIABLE UUID>
In the case of a build where the minor version changes, you can set the value of MY_BUILD_NUMBER to 0 again using the same API, and apply the same logic described above.
Hope that helps! Let me know in case you have any questions.
Thank you, @Motty Cohen !
Patrik S
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.