Configuring pre-receive hooks in Bitbucket

You must configure and deploy a pre-receive hook to the Git repository in Bitbucket to enforce process for Git push operations.

About this task

On Linux, the Git repositories are located by default under /var/atlassian/application-data/Bitbucket/shared/data/repositories. The following steps assume that the Git repositories are in this location. Repeat this task for each Git repository.

To find the Git repository in the repositories folder corresponding to a Git repository in the Bitbucket web interface, follow the steps mentioned in Identifying a Repository on the Bitbucket Server.


  1. Create a folder named pre-receive.d under /var/atlassian/application-data/Bitbucket/shared/data/repositories/repository-ID/hooks.
  2. Copy the pre-receive hook file from EWM-git-integration-toolkit-install-folder/server/hooks/examples/bitbucket/pre-receive to /var/atlassian/application-data/Bitbucket/shared/data/repositoriesrepository-ID/hooks/pre-receive.d.
  3. Assign executable permission to the file: chmod +x pre-receive
  4. Open the pre-receive file in a text editor and set the following environment variables:
    Environment variable Description
    NODE_EXECUTABLE Absolute path to the node executable. Required if node executable cannot be found in the system path.
    RTC_GIT_SERVER_TOOLKIT_PATH Absolute path to the folder where the EWM Git Integration Toolkit has been installed.
    RTC_GIT_SERVER_TRACE_LEVEL Logging level for the hooks. Set this value to 4 while you set up the integration. Revert it after you validate the integration.