【问题标题】:See the branches of a repository in Jenkins在 Jenkins 中查看存储库的分支
【发布时间】:2016-12-27 04:58:56
【问题描述】:

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

【问题讨论】:

  • 您使用的是哪个 VCS?并且你想用 jenkins 建立一个特定的分支。请详细说明你的问题。
  • 配合git,使用多分支管道

标签: jenkins branch bamboo


【解决方案1】:

存储库中的分支可以反映在 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

localhost:8080/script 或 jenkinsurl/script 中运行上述代码
这将显示分支列表。 你可以在任何 groovy 接受的脚本控制台中运行这个 sn-p 代码。 请注意,jenkins 内置具有运行 groovy 脚本的能力。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 2011-03-03
    • 1970-01-01
    • 2021-10-24
    • 1970-01-01
    • 2013-04-10
    • 2021-10-09
    相关资源
    最近更新 更多