Skip to content

Instantly share code, notes, and snippets.

@alekseykorzun
Last active August 29, 2015 13:57
Show Gist options
  • Save alekseykorzun/9901938 to your computer and use it in GitHub Desktop.
Save alekseykorzun/9901938 to your computer and use it in GitHub Desktop.
Automaticly purge build tags that were cut by Jenkins
# Purge old tags
tag_limit=8
tag_current=`git tag -n |grep -i "jenkins-${JOB_NAME}" | wc -l`
if [ $tag_limit -lt $tag_current ]; then
tag_difference=`expr $tag_current - $tag_limit `
git tag |grep -i "jenkins-${JOB_NAME}" | head -$tag_difference | xargs git push --delete origin
git tag |grep -i "jenkins-${JOB_NAME}" | head -$tag_difference | xargs git tag -d
fi
# Create tag
git push --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment