2016-12-27 115 views
0

我想查看Jenkins仪表板中版本控制中存在的所有分支。如果任何分支被推送,它也应该在詹金斯中复制。我如何得到它? 我需要使用任何插件吗?这在Bamboo中是可行的。我试图通过Jenkins管理我的版本控制。查看Jenkins中储存库的分支

+0

您正在使用哪种VCS?你想用詹金斯建立一个特定的分支。请详细说明你的问题。 –

+0

使用git,使用多分支管道 – Rik

回答

0

存储库中的分支可以在jenkins中反映出来,但是您需要具体指明您尝试运行的级别。 要么你想用新的分支名称工作,要么你只是一个下拉菜单来列出分支。

def ant = new AntBuilder() 
ant.exec(
outputproperty:"text", 
     errorproperty: "error", 
     resultproperty: "exitValue", 
failonerror: false, 
executable: 'svn') 
{ 
arg(line:"""list  https://REPOSITORY/branches/""") 
} 
def result = new Expando(
    text: ant.project.properties.text, 
    error: ant.project.properties.error, 
    exitValue: ant.project.properties.exitValue as Integer, 
    toString: {text} 
) 
if (result.exitValue != 0){ 
    throw new Exception("""command failed with ${result.exitValue} 
executed: ${commandLiteral} 
error: ${result.error} 
text: ${result.text}""") 
} 
print result 

运行在上述代码本地主机:8080 /脚本或jenkinsurl /脚本
这将显示分支的列表。 你可以在任何groovy接受的脚本控制台中运行这段代码。 请注意,jenkins inbuilt具有运行groovy脚本的功能。