Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to reset build number for a new minor version

Motty Cohen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 20, 2023


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?


1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 21, 2023

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.


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

Suggest an answer

Log in or Sign up to answer
Site Admin
AUG Leaders

Atlassian Community Events