2017-05-29 16 views
0

gitブランチの名前を取得しようとしていますが、次のコードは期待される出力を返しません。Jenkinsパイプラインスクリプト - gitブランチを変更する

def getbranches = ("git ls-remote -h https://github.com/my_repo").execute().getText() 

print getbranches.readLines() 
.collect { it.split()[1].replaceAll("refs/heads/", "") } 
.unique() 
.findAll { it.startsWith('r') } 

それはのようなものを返す必要があります:リリース/ 1.1をそれはを出力します。

答えて

0

次のコードは、私の仕事:

git url: 'https://github.com/my_repo', branch: 'master' 

def getBranch = bat (returnStdout : true, script: "\"C:\\Program Files\\Git\\bin\\sh.exe\" --login -c \"git branch -a | grep remotes/origin/release/[^/]*\$ | cut -d/-f 4\"") 
String[] getReleaseVersion = getBranch.split('\n') 
関連する問題