From 9bc8463ec725e9d2c668243792a8d5a674556393 Mon Sep 17 00:00:00 2001 From: nstapelbroek Date: Mon, 22 Dec 2014 07:23:12 -0800 Subject: [PATCH] Included an example of a hook with commiter and message parameter --- Autobuilding from Atlassian Stash.md | 28 ++++++++++++++++++++++++++ Autobuilding-from-Atlassian-Stash.rdoc | 11 ---------- 2 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 Autobuilding from Atlassian Stash.md delete mode 100644 Autobuilding-from-Atlassian-Stash.rdoc diff --git a/Autobuilding from Atlassian Stash.md b/Autobuilding from Atlassian Stash.md new file mode 100644 index 0000000..661f66f --- /dev/null +++ b/Autobuilding from Atlassian Stash.md @@ -0,0 +1,28 @@ +It is possible to use Stashes External Post Receive Hooks. +Create a post_receive.sh script with execution rights. +Have the EPRH execute the shell script with a positional parameter of your PHPCI build id. + + PROJECT_ID=$1 + PHPCI_URL="http://ci.site.com" + 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 + +Optional, here is a way to send the stash user e-mail and the first 50 characters of the commit message. +``` +#!/bin/bash +PROJECT_ID=$1 +PHPCI_URL="http://ci.site.com" +while read from_ref to_ref ref_name; do + BRANCH=$(git rev-parse --symbolic --abbrev-ref $ref_name) + COMMITMESSAGE=$(git log -n 1 --pretty=format:%s $to_ref | cut -c1-50) + curl -G \ + "$PHPCI_URL/webhook/git/$PROJECT_ID" \ + --data branch=$BRANCH \ + --data commit=$to_ref \ + --data committer=$STASH_USER_EMAIL \ + --data-urlencode message="$COMMITMESSAGE" +done +``` \ No newline at end of file diff --git a/Autobuilding-from-Atlassian-Stash.rdoc b/Autobuilding-from-Atlassian-Stash.rdoc deleted file mode 100644 index 0f27495..0000000 --- a/Autobuilding-from-Atlassian-Stash.rdoc +++ /dev/null @@ -1,11 +0,0 @@ -It is possible to use Stashes External Post Receive Hooks. -Create a post_receive.sh script with execution rights. -Have the EPRH execute the shell script with a positional parameter of your PHPCI build id. - - PROJECT_ID=$1 - PHPCI_URL="http://ci.site.com" - 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 \ No newline at end of file