Skip to content

Commit dbdd2a8

Browse files
authored
Allow forward slashes in working branch names (#376)
When a branch is named something like 'enhance/stf-1234' the 'working_branch' value will be invalid as only the first field delimited by a forward-slash will be used. This change increases the range of fields from 3 and onward.
1 parent 9550524 commit dbdd2a8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Jenkinsfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ pipeline {
103103
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
104104
checkout scm
105105
script {
106-
working_branch = sh(script: 'git ls-remote --heads origin | grep $(git rev-parse HEAD) | cut -d / -f 3', returnStdout: true).toString().trim()
106+
working_branch = sh(script: 'git ls-remote --heads origin | grep $(git rev-parse HEAD) | cut -d / -f 3-', returnStdout: true).toString().trim()
107107
if (!working_branch) {
108108
// in this case, a merge with the base branch was required thus we use the second to last commit
109109
// to find the original topic branch name
110-
working_branch = sh(script: 'git ls-remote --heads origin | grep $(git rev-parse HEAD~1) | cut -d / -f 3', returnStdout: true).toString().trim()
110+
working_branch = sh(script: 'git ls-remote --heads origin | grep $(git rev-parse HEAD~1) | cut -d / -f 3-', returnStdout: true).toString().trim()
111111
}
112112
}
113113
sh "git checkout -b ${working_branch}"

0 commit comments

Comments
 (0)