Skip to content

Instantly share code, notes, and snippets.

@graymic
Created June 4, 2014 09:33
Show Gist options
  • Save graymic/85fcb0eb017e4853a0b3 to your computer and use it in GitHub Desktop.
Save graymic/85fcb0eb017e4853a0b3 to your computer and use it in GitHub Desktop.
The purpose of this script is to allow Atlassian Stash to send post-receive hooks to PHPCI
#!/bin/bash
# Author: Michael Gray
# Description: The purpose of this script is to allow Atlassian Stash to send post-receive hooks to PHPCI
# using the external post-receive POST hook request.
# Email: hello@graymic.co.uk
(
PROJECT_ID=$1
PHPCI_URL="http://path.to.ci.server.com"
echo "Script name: $0"
echo "Positional arguments: ${@}"
echo "STASH_USER_NAME: $STASH_USER_NAME"
echo "STASH_USER_EMAIL: $STASH_USER_EMAIL"
echo "STASH_REPO_NAME: $STASH_REPO_NAME"
echo "STASH_IS_ADMIN: $STASH_IS_ADMIN"
while read from_ref to_ref ref_name; do
BRANCH=$(git rev-parse --symbolic --abbrev-ref $ref_name)
echo "Sending webhook"
curl "$PHPCI_URL/webhook/git/$PROJECT_ID?branch=$BRANCH&commit=$to_ref"
done
) | tee -a /tmp/atlassian-post-receive.log
@graymic
Copy link
Author

graymic commented Jun 4, 2014

Ensure you make the post-receive.sh script executable before assigning the post-receive hook in stash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment