27 lines
664 B
Groovy
27 lines
664 B
Groovy
ext.getGitVersionCode = { ->
|
|
try {
|
|
def stdout = new ByteArrayOutputStream()
|
|
exec {
|
|
commandLine 'git', 'rev-list', '--first-parent', '--count', 'master'
|
|
standardOutput = stdout
|
|
}
|
|
return Integer.parseInt(stdout.toString().trim())
|
|
}
|
|
catch (ignored) {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
ext.getGitVersionName = { ->
|
|
try {
|
|
def stdout = new ByteArrayOutputStream()
|
|
exec {
|
|
commandLine 'git', 'describe', '--always', '--tags', '--dirty'
|
|
standardOutput = stdout
|
|
}
|
|
return stdout.toString().trim()
|
|
}
|
|
catch (ignored) {
|
|
return null;
|
|
}
|
|
} |