#!/bin/bash REPO="My-Job-Name" TOKEN="token from jenkins" JENKINSURL="http://login:password@jenkins.localhost/" declare -A branches while read oldrev newrew ref; do if [ -z $ref ]; then ref=$newrev newrev="" fi echo "$oldrev $newrev $ref" >> /var/log/githook/githook.log if [ "${ref:0:11}" = "refs/heads/" ]; then branch=${ref:11} branches["${branch}"]="${branch}" fi done for branch in "${branches[@]}"; do echo "Project ${REPO} building ${branch}" >> /var/log/githook/git-post-receive.log curl -o /tmp/aaa.tmp --silent "${JENKINSURL}/job/${REPO}/buildWithParameters?token=${TOKEN}&cause=GIT+push&BRANCH=${branch}" >> /var/log/githook/git-post-receive.log done