How to retrieve which commit hashes are included in a expired or deleted Bamboo build
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
Platform Notice: Data Center Only - This article only applies to Atlassian products on the data center platform.
Summary
After a build result is expired or deleted from Bamboo, it's not possible to retrieve which were the commits of those builds.
However if the build is consuming a Bitbucket repository the information is still available in Bitbucket's database.
Environment
This information available only for Bamboo plans that consume Bitbucket server/DC repositories.
Solution
Using the following SQL statement it's possible to retrieve all builds that contained a specific commitID:
SELECT
BBS.commit_id,
BBS.name,
BBS.build_key,
BBS.build_number,
BBS.created_date,
BBS.updated_date,
BBS.ref
FROM
public.bb_build_status BBS
WHERE
BBS.commit_id LIKE '%6afb46fde71%'
Substitute 6afb46fde71 with the commit id and the results will display all the builds associated with that commit id.
Using the following SQL statement it's possible to retrieve all commits that contained a specific build key:
SELECT
BBS.commit_id,
BBS.name,
BBS.build_key,
BBS.build_number,
BBS.created_date,
BBS.updated_date,
BBS.ref
FROM
public.bb_build_status BBS
WHERE
BBS.build_key LIKE '%PLAN-KEY%'
Substitute PLAN-KEY with the plan key