Created
January 17, 2014 17:54
-
-
Save samukasmk/8478134 to your computer and use it in GitHub Desktop.
Cron Job like git hook, to inform the Jenkins|Hudson ScriptTrigger Plugin to do a build. - by Samuel Maciel Sampaio
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/bash# | |
# | |
# check_git_remote_changes.sh | |
# By: Samuel Maciel Sampaio <20140115> | |
# | |
# Cron Job like git hook, to inform the Jenkins|Hudson | |
# ScriptTrigger Plugin to do a build. | |
# Plugin: https://wiki.jenkins-ci.org/display/JENKINS/ScriptTrigger+Plugin | |
GIT_REPO_FOLDER=$1 | |
if [ -z "$GIT_REPO_FOLDER" ]; then | |
echo "usage: $0 <GIT_REPO_FOLDER>"; | |
exit 1; | |
fi | |
fetch_output=$( | |
git --git-dir "$GIT_REPO_FOLDER/.git" \ | |
--work-tree "$GIT_REPO_FOLDER" \ | |
fetch --dry-run 2>&1 | |
) | |
echo $fetch_output | grep "^From" | |
grep_exit_code=$? | |
if [ "$grep_exit_code" -eq "0" ]; then | |
git --git-dir "$GIT_REPO_FOLDER/.git"\ | |
--work-tree "$GIT_REPO_FOLDER" \ | |
fetch | |
git --git-dir "$GIT_REPO_FOLDER/.git"\ | |
--work-tree "$GIT_REPO_FOLDER" \ | |
fetch --tags | |
exit 0 | |
else | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment