modified version of jenkins debian glue (https://github.com/mika/jenkins-debian-glue) for devuan
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

63 lines
1.5 KiB

#!/bin/sh
# git hook: post-receive
# !!! PLEASE ADJUST !!!
projectname=ADJUSTME
token=ADJUSTME
trigger_jenkins()
{
oldrev=$(git rev-parse $1)
newrev=$(git rev-parse $2)
refname="$3"
if expr "$oldrev" : '0*$' >/dev/null ; then
change_type="create"
else
if expr "$newrev" : '0*$' >/dev/null ; then
change_type="delete"
else
change_type="update"
fi
fi
newrev_type=$(git cat-file -t "$newrev" 2> /dev/null)
oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
case "$change_type" in
create|update)
rev="$newrev"
rev_type="$newrev_type"
;;
delete)
return # we are not interested in deletes
;;
esac
case "$refname","$rev_type" in
refs/heads/*,commit)
# branch
refname_type="branch"
branch_name=${refname##refs/heads/}
esac
echo "Detected branch $branch_name"
# request autobuild in jenkins.grml.org
if wget --tries=2 --dns-timeout=5 --connect-timeout=5 --read-timeout=5 \
-O /dev/null "http://jenkins.grml.org/job/${projectname}/buildWithParameters?token=$token&branch=origin/${branch_name}" >/dev/null 2>&1 ; then
echo "Triggered autobuild at http://jenkins.grml.org/job/${projectname}/lastBuild/"
else
echo "Could not trigger autobuild at jenkins.grml.org (project not present/set up?)"
fi
}
if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
trigger_jenkins $2 $3 $1
else
while read oldrev newrev refname; do
trigger_jenkins $oldrev $newrev $refname
done
fi
# vim:foldmethod=marker ts=2 ft=sh ai expandtab sw=2