Changing the current build number in Bamboo
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:
- BAM-10282 - Getting issue details... STATUS
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:
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:
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_id | build_type | created_date | updated_date | full_key | buildkey | title | description | first_build_number | latest_build_number | next_build_number | ... |
---|---|---|---|---|---|---|---|---|---|---|---|
393217 | CHAIN | 2015-07-01 11:13:31.868000 | 2015-07-01 11:50:22.936000 | MORG-SUPSQL | SUPSQL | Support SQL | Test builder for SQL support scripts | 1 | 5 | 6 | ... |
393218 | JOB | 2015-07-01 11:13:31.997000 | 2015-07-01 11:17:57.343000 | MORG-SUPSQL-JOB1 | JOB1 | Default Job | NULL | 1 | 5 | 6 | ... |
393221 | CHAIN_BRANCH | 2015-07-01 11:50:40.932000 | 2015-07-01 11:52:20.094000 | MORG-SUPSQL0 | SUPSQL0 | feature-bamboo-buildnum | Test builder for SQL support scripts | 1 | 8 | 9 | ... |
393222 | JOB | NULL | NULL | MORG-SUPSQL0-JOB1 | JOB1 | Default Job | NULL | 1 | 8 | 9 | ... |
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>%';