This script will echo all data that available to the hook back to the user on git push. Useful for debugging.
Script #
Place the following script under the
<bitbucket-home-dir>/external-hooks/test-script.sh
path:
#!/bin/bash
echo "Script name: $0"
echo "Positional arguments: ${@}"
echo 'Environment variables'
echo "BB_HOOK_TRIGGER_ID: $BB_HOOK_TRIGGER_ID"
echo "BB_HOOK_TYPE: $BB_HOOK_TYPE"
echo "BB_IS_DRY_RUN: $BB_IS_DRY_RUN"
echo "BB_PROJECT_KEY: $BB_PROJECT_KEY"
echo "BB_REPO_SLUG: $BB_REPO_SLUG"
echo "BB_REPO_IS_FORK: $BB_REPO_IS_FORK"
echo "BB_REPO_IS_PUBLIC: $BB_REPO_IS_PUBLIC"
echo "BB_BASE_URL: $BB_BASE_URL"
echo "BB_REPO_CLONE_SSH: $BB_REPO_CLONE_SSH"
echo "BB_REPO_CLONE_HTTP: $BB_REPO_CLONE_HTTP"
echo "BB_USER_NAME: $BB_USER_NAME"
echo "BB_USER_DISPLAY_NAME: $BB_USER_DISPLAY_NAME"
echo "BB_USER_EMAIL: $BB_USER_EMAIL"
echo "BB_USER_PERMISSION: $BB_USER_PERMISSION"
while read from_ref to_ref ref_name; do
echo "Ref update:"
echo " Old value: $from_ref"
echo " New value: $to_ref"
echo " Ref name: $ref_name"
echo " Diff:"
git show $from_ref..$to_ref | sed 's/^/ /'
done
exit 1
Configuration #
Type: Pre Receive
Executable: test-script.sh
Safe mode: [v]
Positional arguments: any number of test arguments
After these actions are done, you should able to see that hook is working: