Created
June 4, 2014 09:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ensure you make the post-receive.sh script executable before assigning the post-receive hook in stash.