Created
December 11, 2020 08:17
-
-
Save mat127/7bc996d46d2eb31130324b3e045b780c to your computer and use it in GitHub Desktop.
Mercurial changegroup hook triggering a Jenkins job build only if particular branch is changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
JENKINS_URL=http://hg.somewhere.net | |
JENKINS_TOKEN=token | |
JENKINS_JOB="" | |
HG_REPOSITORY=/path/to/repository | |
HG_BRANCH="" | |
HG_NODE="" | |
while [[ "$#" -gt 0 ]]; do | |
case $1 in | |
-j|--job) JENKINS_JOB="$2"; shift ;; | |
-b|--branch) HG_BRANCH="$2"; shift ;; | |
-n|--node) HG_NODE="$2"; shift ;; | |
*) echo "Unknown parameter passed: $1"; exit 1 ;; | |
esac | |
shift | |
done | |
LOG_LINE_COUNT=$(hg log -R $HG_REPOSITORY -r $HG_NODE: -b $HG_BRANCH | wc -l) | |
if [ $LOG_LINE_COUNT -gt 0 ] | |
then | |
curl --silent $JENKINS_URL/job/$JENKINS_JOB/build?token=$JENKINS_TOKEN | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment