Get default reviewers API in Bitbucket Datacenter fails with NoSuchBranchException
プラットフォームについて: 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 は除く
要約
The API to get default reviewers in Bitbucket Datacenter fails with NoSuchBranchException.

環境
The solution has been validated in Bitbucket Datacenter 8.9.5 but may be applicable to other Bitbucket 8.x versions
診断
The below API returns NoSuchBranchException, though the branch exists in the Bitbucket repository.
curl -u <ADMIN_USERNAME> --request GET --url 'http://{baseurl}/rest/default-reviewers/latest/projects/{projectKey}/repos/{repositorySlug}/reviewers?sourceRepoId=${sourceRepoId}&targetRepoId=${targetRepoId}&sourceRefId=${sourceRefId}&targetRefId=${targetRefId}' --header 'Accept: application/json'
Parameters:
sourceRepoId = The ID of the repository in which the source ref exists
targetRepoId = The ID of the repository in which the target ref exists
sourceRefId = The ID of the source ref
targetRefId = The ID of the target ref
For example,
curl -u <ADMIN_USERNAME> --request GET --url 'http://{baseurl}/rest/default-reviewers/latest/projects/PRJ/repos/repo1/reviewers?sourceRepoId=${sourceRepoId}&targetRepoId=${targetRepoId}&sourceRefId=${source-commit-hash}&targetRefId=${target-commit-hash}' --header 'Accept: application/json'原因
Prior to Bitbucket 8.0, it was possible to pass a commit hash to sourceRefId and targetRefID parameters in the API to review the results. Starting with Bitbucket 8.x, a commit hash is not considered as a valid RefID. A valid RefID would be a branch or a tag name.
ソリューション
A valid RefID such as a branch name or tag name is to be passed to sourceRefID and targetRefID parameter values to run the API successfully and retrieve default reviewers.
curl -u <ADMIN_USERNAME> --request GET --url 'http://{baseurl}/rest/default-reviewers/latest/projects/PRJ/repos/repo1/reviewers?sourceRepoId=${sourceRepoId}&targetRepoId=${targetRepoId}&sourceRefId=${source-branchname}&targetRefId=${target-branchname}' --header 'Accept: application/json'この内容はお役に立ちましたか?