Skip to content
Snippets Groups Projects
Commit 2f658987 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

Jenkins compactible branch name script

parent de08f975
No related branches found
No related tags found
No related merge requests found
......@@ -197,7 +197,7 @@ def getVersionNameFromGit() {
// get last tag in current branch
exec {
commandLine 'git', 'describe', '--abbrev=0', '--tags', '--first-parent'
commandLine 'git', 'describe', '--abbrev=0', '--tags'
standardOutput = stdout
}
String result = stdout.toString().trim();
......@@ -206,14 +206,7 @@ def getVersionNameFromGit() {
if (!"master".equals(branchName)) {
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--tags', '--no-walk', '--max-count=1', '--first-parent'
standardOutput = stdout
}
String revision = stdout.toString().trim()
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', "${revision}..HEAD", '--count', '--first-parent'
commandLine 'git', 'rev-list', "${result}..HEAD", '--count'
standardOutput = stdout
}
String numberOfCommits = stdout.toString().trim()
......@@ -241,10 +234,11 @@ def getVersionCodeFromGit() {
def getBranchNameFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'symbolic-ref', '--short', 'HEAD'
commandLine 'git', 'describe', '--contains', '--all', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim().toLowerCase()
String branchString = stdout.toString().trim()
return branchString.contains("/") ? branchString.substring(branchString.lastIndexOf("/") + 1) : branchString
}
def getMapConvertedToString(Map map) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment