Changing the current build number in Bamboo

Still need help?

The Atlassian Community is here for you.

Ask the community

Problem

Currently the Bamboo UI does not provide the ability to edit the build number. Internally, Bamboo references previous builds from multiple tables so it is non-trivial to modify the build number. While it is possible to increase the build number with the workarounds below, decreasing it is not possible.

There is a feature request to add this capability but at the time of this writing it has not yet been implemented:

Please vote on the feature request if it's something you'd like to see implemented in the future. For more information see Implementation of New Features Policy.

Workaround

Bamboo newer than 5.10.0

Workaround: Reset the build number

If you need to "reset" the build number to 1 this can be achieved by cloning the build plan via the Create menu, Clone plan.

After cloning and verifying all is configured correctly delete the old build plan and revise all external links to point to the new one.

Cloning a plan will not clone build result history or plan branches.

Workaround: Increase the build number in the database

The build number can be increased but should never be decreased. There are many tables referencing existing build results and this is too complex for a simple SQL update. If the build number is set to a number used in the past it will cause serious problems.

With that said, increasing the number to a larger value is straightforward. Locate the appropriate build plan to modify by retrieving records in the BUILD and BUILD_NUMBERS tables:

Locate the build plan to modify
SELECT * FROM BUILD_NUMBERS JOIN BUILD USING (BUILD_ID) ORDER BY FULL_KEY;


In the example output below there are two entries. These are for the same plan in Bamboo. You'll also see BUILD_TYPE CHAIN_BRANCH which is a branch of the plan. Only increment these if you want them to be the same as the master, but generally these are their own entities.

Example:

BUILD_ID

BUILD_NUMBERS_ID

NEXT_BUILD_NUMBER

BUILD_TYPE

CREATED_DATE

UPDATED_DATE

FULL_KEY

BUILDKEY

TITLE

360449

458753

3

CHAIN

2016-08-04 18:13:37

2016-08-04 18:34:34

RP-RPO

RPO

Remote Plan One

1769473

2064385

1

CHAIN_BRANCH

2016-10-10 21:00:23

2016-10-10 21:00:23

RP-RPO0

RPO0

Test

When you know which build plan to modify you can run this SQL to increase the number.

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

UPDATE BUILD_NUMBERS
SET NEXT_BUILD_NUMBER = 9999
WHERE BUILD_ID in (SELECT BUILD_ID FROM BUILD WHERE FULL_KEY = '<PROJECT KEY>-<PLAN KEY>');

For branch builds the syntax is slightly different. Locate the correct BRANCH_NUMBER by examining the BUILDKEY field in the BUILD table.

UPDATE BUILD_NUMBERS
SET NEXT_BUILD_NUMBER = 9999
WHERE BUILD_ID in (SELECT BUILD_ID FROM BUILD WHERE FULL_KEY LIKE '<PROJECT KEY>-<PLAN KEY><BRANCH_NUMBER>%');


Bamboo older than version 5.10.0

Workaround: Reset the build number

If you need to "reset" the build number to 1 this can only be achieved by cloning the build plan via the Create menu, Clone an existing plan.

After cloning and verifying all is configured correctly delete the old build plan and revise all external links to point to the new one.

Cloning a plan will not clone build result history or plan branches.

Workaround: Increase the build number in the database

The build number can be increased but should never be decreased. There are many tables referencing existing build results and this is too complex for a simple SQL update. If the build number is set to a number used in the past it will cause serious problems.

Increasing the number to a larger value is straightforward. Locate the appropriate build plan to modify by retrieving records in the BUILD table:

Locate the build plan to modify
SELECT * FROM BUILD ORDER BY FULL_KEY;


In this example there are two entries. These are for a single plan in Bamboo, there's one of BUILD_TYPE CHAIN and one of JOB. If there are multiple jobs in a build you will have multiple entries with the JOB BUILD_TYPE. Each of these must be increased to the same number or you'll have problems. You'll also see BUILD_TYPE CHAIN_BRANCH which is a branch of the plan. Only increment these if you want them to be the same as the master, but generally these are their own entities. A BUILD_TYPE of JOB is common to both the main and branch plans.

Example:

build_idbuild_typecreated_dateupdated_datefull_keybuildkeytitledescriptionfirst_build_numberlatest_build_numbernext_build_number...
393217CHAIN2015-07-01 11:13:31.8680002015-07-01 11:50:22.936000MORG-SUPSQLSUPSQLSupport SQLTest builder for SQL support scripts156...
393218JOB2015-07-01 11:13:31.9970002015-07-01 11:17:57.343000MORG-SUPSQL-JOB1JOB1Default JobNULL156...
393221CHAIN_BRANCH2015-07-01 11:50:40.9320002015-07-01 11:52:20.094000MORG-SUPSQL0SUPSQL0feature-bamboo-buildnumTest builder for SQL support scripts189...
393222JOBNULLNULLMORG-SUPSQL0-JOB1JOB1Default JobNULL189...

When you know which build plan to modify you can run this SQL to increase the number.

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

UPDATE BUILD
SET NEXT_BUILD_NUMBER = 9999
WHERE (FULL_KEY LIKE '<PROJECT KEY>-<PLAN KEY>%' OR FULL_KEY LIKE '<PROJECT KEY>-<PLAN KEY>-JOB%')
  AND MASTER_ID IS NULL; 

For branch builds the syntax is slightly different. Locate the correct BRANCH_NUMBER by examining the BUILDKEY field in the BUILD table.

UPDATE BUILD
SET NEXT_BUILD_NUMBER = 9999
WHERE FULL_KEY LIKE '<PROJECT KEY>-<PLAN KEY><BRANCH_NUMBER>%'; 

Last modified on Dec 24, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.