Created
April 14, 2020 17:10
-
-
Save nightcrawler-/7da21778262b1ccb929c68a4db496558 to your computer and use it in GitHub Desktop.
This file contains 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
// Gets the version code -- number of git tags to this end | |
def getVersionCode = { -> | |
try { | |
def code = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'tag', '--list' | |
standardOutput = code | |
} | |
return code.toString().split("\n").size() | |
} | |
catch (ignored) { | |
return -1 | |
} | |
} | |
// Gets the version name from the latest Git tag | |
def getVersionName = { -> | |
try { | |
def stdout = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'describe', '--tags', '--dirty' | |
standardOutput = stdout | |
} | |
return stdout.toString().trim() | |
} | |
catch (ignored) { | |
return null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment