How to extract build status of all the commits directly from the Bitbucket Data Center database
プラットフォームについて: Data Center のみ。 - This article only applies to Atlassian apps on the Data Center プラットフォーム。
この KB は Data Center バージョンの製品用に作成されています。Data Center 固有ではない機能の Data Center KB は、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。 Server* 製品のサポートは 2024 年 2 月 15 日に終了しました。Server 製品を実行している場合は、 アトラシアン Server サポート終了 のお知らせにアクセスして、移行オプションを確認してください。
*Fisheye および Crucible は除く
要約
Bitbucket provides a mechanism for a build server to store the status of the build related to a commit using a REST endpoint. Whilst the REST API allows the developer to store and retrieve the build status related to single or multiple specified commits there is no API to extract the build status related to all commits. This knowledge-base article describes one method you can use to retrieve the build status of all commits via running a SQL query on the Bitbucket database.
ソリューション
Bitbucket will store an entry of the build status, that has been posted to it by the build engine in the bb_build_status table. The following SQL will extract the entries from the table and list the commit, build status, build plan, date and the corresponding repository.
The below query has been developed on PostgreSQL and may require some tweaking depending on the database engine that Bitbucket is using.
select bs.commit_id commit, bs.state state, bs.build_key build_key, bs.build_number build_number , bs.updated_date build_date, p.name project, r.name repository from bb_build_status bs
join (
select commit_id, max(updated_date) latest
from bb_build_status group by commit_id
) l on bs.commit_id =l.commit_id and bs.updated_date = l.latest
join repository r on r.id = bs.repository_id
join project p on p.id= r.project_id;この内容はお役に立ちましたか?