How to bypass Verify Committer Hook in Bitbucket Data Center
プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。
このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
要約
In Bitbucket, the Verify Committer Hook is enabled at either the Project or Repository level and user validation through the Verify Committer Hook needs to be bypassed for service users.
環境
Bitbucket Server 7.21.19
Applies to Bitbucket Server/Data Center 8.x
ソリューション
There are two possible approaches to bypass the Verify Committer Hook in Bitbucket as below. Users can follow either of them.
First Approach: By using Project or Repository level HTTP Access Token (not user personal access token).
- In this approach, the user needs to create a Project/Repository HTTP Access Token with the required permission for the service account user.
- Once it is done, the user needs to share the below REST API call with the team members (Developers) with the newly created HTTP Access Token to clone the repositories in their environment or machines.
git clone -c http.extraHeader='Authorization: Bearer NzgwNzI5NTk1OTk0REDSFSHAiVExf712ERTYUIP' <Repository Clone URL>
Here replace NzgwNzI5NTk1OTk0REDSFSHAiVExf712ERTYUIP with your newly generated Project/Repository HTTP access token and <Repository Clone URL> with your repository clone url.
Example:
git clone -c http.extraHeader='Authorization: Bearer NzgwNzI5NTk1OTk0ASDFGHJKLOIKFhI9' https://linux-host/bitbucket/scm/test/test_token.git
- Once, Developers are done with the clone of the repository and performs the push the code after changes, the token approach should bypass Verify Committer Hook.
- Push log under Repository settings will help user to monitor the Developers details who has performed the changes in the repository.
Second Approach: Using .mailmap file (explaining below as bare repository example)
- In this approach, just think Verify Committer Hook is not enabled on the repository.
- User need to clone the bare repository from Bitbucket on the client machine.
- Once done, need to create a .mailmap file (like any text file) and need to add the following entry for each user:
User1_name <User1_EmailID> User2_name <User2_EmailID>
Here User2_name and <User2_EmailID> are the names and email id of the users who should be bypassed (developer details).
User1_name and <User1_EmailID> are the name and email ID of the user which should be replaced with User2 (means service user).
Example: service_user <service_user@xyz.com> developer1 <developer1@xyz.com>
Note:
a. Please don't remove <> signs before and after email id. Email id should be with <> signs like <service_user@xyz.com>
b. User can add multiple entries in the same pattern.
- Once done, place a commit and push the changes (which means push the .mailmap file to Bitbucket).
- Now Enable Verify Committer Hook in Bitbucket UI.
- Advise Developer team to clone the repository on their local machines and push the changes after applying any modification to the code like any other file present in the repository or by creating a new file in the cloned repository.
- Once done, verify the behavior and share the result with us.
- Here also, Push log under Repository settings will help user to monitor the developer details who has performed the changes in the repository.