Reputation: 13
In my Jenkins pipeline, I'm trying to get this output into an array:
gitBranches = sh (
script: 'git branch -a',
returnStdout: true).trim()
Is that possible?
Upvotes: 1
Views: 2182
Reputation: 1621
Can be done in groovy
way:
gitBranchStr = sh (
script: 'git branch -a',
returnStdout: true)
gitBranchList = gitBranchStr.substring(gitBranchStr.lastIndexOf("*") + 1).split("\n")*.trim()
Upvotes: 1