Skip to content

Instantly share code, notes, and snippets.

@le6o
Last active August 29, 2015 14:12
Show Gist options
  • Save le6o/1ea9bf2cfebf9ec5c280 to your computer and use it in GitHub Desktop.
Save le6o/1ea9bf2cfebf9ec5c280 to your computer and use it in GitHub Desktop.
Grab version number from last merged GitHub pull request of a gitflow release branch
#!/bin/bash
TAG=$(git log --format=%s --merges -n 1 | cut -d '/' -f 3)
if ! [[ $TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
return 1
fi
echo "TAG = $TAG" > properties
# Used as a jenkins build step to grab the version number from the last
# merged GitHub pull request commit message.
# Assumes you are building on master and that you've just merged a gitflow
# release branch of the form, release/1.2.3 via GitHub pull request.
# Requires the EnvInject Plugin to read variables from the properties file.
# The variable $TAG can then be used with the git publisher plugin to push the tag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment