Françoisスクリプトのより精巧なバージョンは次のようになります
#!/bin/bash
JENKINS_URL="http://192.168.1.116/jenkins"
GIT_URL="git@bitbucket.org:nuclos/nuclos.git"
# remove all spaces and newlines from ARG
trim() {
local ARG="$1"
shift
echo -e "$ARG" | tr -d "[:space:]\n"
}
# unique sort ARG items separated by newlines
unique() {
local ARG="$1"
shift
echo -e "$ARG" | sort -u -i
}
# cut first and last character from ARG
cutfl() {
local ARG="$1"
shift
local LEN="${#ARG}"
let LEN="$LEN - 2"
echo "${ARG:1:$LEN}"
}
BRANCHES=""
while read oldrev newrev refname; do
BRANCH=`trim ${refname#refs/heads/}`
if [ -n "$BRANCH" ]; then
BRANCHES+="${BRANCH}\n"
fi
done
BRANCHES=`unique "$BRANCHES" | tr '\n' ','`
BRANCHES=`cutfl "$BRANCHES"`
echo wget -q -O - "$JENKINS_URL/git/notifyCommit?url=$GIT_URL&branches=$BRANCHES"
at "now + 5 minutes" <<END
wget -q -O - "$JENKINS_URL/git/notifyCommit?url=$GIT_URL&branches=$BRANCHES"
END
このバージョンは複数のブランチに対応でき、各ブランチに対して1つのビルドのみをトリガーします。