1
0
Fork 0

simplified the version generation during build time and got rid of the deprecated exec{}

This commit is contained in:
sspanak 2025-03-11 14:41:56 +02:00 committed by Dimo Karaivanov
parent 8ea702c2e2
commit b16af4b1e9

View file

@ -1,26 +1,12 @@
def execThing (String cmdStr) { static def execThing (String cmd) {
def stdout = new ByteArrayOutputStream() return cmd.execute().text.trim()
String prefix = System.getenv("GITCMDPREFIX")
if (prefix != null) {
String cmd = prefix + cmdStr
exec {
commandLine cmd.tokenize()
standardOutput = stdout
}
} else {
exec {
commandLine cmdStr.tokenize()
standardOutput = stdout
}
}
return stdout.toString().trim()
} }
def getCurrentGitHash() { static def getCurrentGitHash() {
return execThing('git rev-parse --short=8 HEAD') return execThing('git rev-parse --short=8 HEAD')
} }
def generateVersionName() { static def generateVersionName() {
// major version // major version
String versionTagsRaw = execThing('git tag --list v[0-9]*') String versionTagsRaw = execThing('git tag --list v[0-9]*')
int versionTagsCount = versionTagsRaw == "" ? 0 : versionTagsRaw.split('\n').size() int versionTagsCount = versionTagsRaw == "" ? 0 : versionTagsRaw.split('\n').size()