Page:
Autobuilding From Git
Pages
Add a Virtual Host
Adding PHPCI Support to Your Projects
Atoum Plugin
Autobuilding from Atlassian Stash
Autobuilding from Git by Cron
Autobuilding From Git
Autobuilding From GitHub
Autobuilding From GitLab
Autobuilding from Bitbucket
Behat plugin
Campfire plugin
Clean build plugin
Codeception plugin
Composer plugin
Configuring PHPCI
Contributing to PHPCI
Copy build plugin
Deployer
Email plugin
Env plugin
Example phpci.yml
Grunt plugin
Hipchat Notify Plugin
Home
Installing PHPCI
Interpolation
Irc plugin
Lint plugin
Logging
Maintainers
MySQL plugin
PHP Code Sniffer plugin
PHP Coding Standards Fixer plugin
PHP Docblock Checker
PHPCI Config
Package build plugin
Pdepend plugin
Phar Plugin
Phing Plugin
Php copy paste detector plugin
Php loc plugin
Php mess detector plugin
Php parallel lint plugin
Php spec plugin
PhpUnit Plugin
Postgresql plugin
Project Status Images and Page
Run Builds Using Cron
Run Builds Using a Daemon
Run Builds Using a Worker
Shell plugin
Slack Notify Plugin
Technical Debt Plugin
Updating PHPCI
Vanilla Installation on OS X 10.10 Yosemite with OS X Server 4
Vanilla Mac Mavericks Server Installation Guide
XMPP notifications plugin
custom plugins setup
6
Autobuilding From Git
Guillaume Perréal edited this page 2015-03-18 13:45:00 +01:00
Table of Contents
Requirements
- A git repository on a server (bare or plain does not matter)
- curl to send the web hook
Installation
- Create a new file
post-receive
inside the githooks
directory with the following content:
#!/bin/sh
PROJECT_ID=1
PHPCI_URL="http://my.server.com/PHPCI/"
trigger_hook() {
NEWREV="$2"
REFNAME="$3"
if [ "$NEWREV" = "0000000000000000000000000000000000000000" ]; then
# Ignore deletion
return
fi
case "$REFNAME" in
# Triggers only on branches and tags
refs/heads/*|refs/tags/*) ;;
# Bail out on other references
*) return ;;
esac
BRANCH=$(git rev-parse --symbolic --abbrev-ref "$REFNAME")
COMMITTER=$(git log -1 "$NEWREV" --pretty=format:%ce)
MESSAGE=$(git log -1 "$NEWREV" --pretty=format:%s)
echo "Sending webhook"
curl \
--data-urlencode branch="$BRANCH" \
--data-urlencode commit="$NEWREV" \
--data-urlencode committer="$COMMITTER" \
--data-urlencode message="$MESSAGE" \
"$PHPCI_URL/webhook/git/$PROJECT_ID"
}
if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
PAGER= trigger_hook $1 $2 $3
else
while read oldrev newrev refname; do
trigger_hook $oldrev $newrev $refname
done
fi
- Change the file to be executable:
chmod a+x post-receive
- Push changes to the repository