Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 在使用作业DSL的多个SCM的情况下,仅对一个存储库进行更改_Git_Jenkins_Bitbucket_Jenkins Job Dsl - Fatal编程技术网

Git 在使用作业DSL的多个SCM的情况下,仅对一个存储库进行更改

Git 在使用作业DSL的多个SCM的情况下,仅对一个存储库进行更改,git,jenkins,bitbucket,jenkins-job-dsl,Git,Jenkins,Bitbucket,Jenkins Job Dsl,我正在通过复制模板作业在Jenkins创建一个新作业。对于带有单个存储库的模板,我使用下面的代码来更改“分支到构建”部分 job('example') { using('template_job') configure { node -> node / scm / branches / 'hudson.plugins.git.BranchSpec' { name 'branchname' } } } 但现在我的模板作业有多个响应,我必须更改分支,

我正在通过复制模板作业在Jenkins创建一个新作业。对于带有单个存储库的模板,我使用下面的代码来更改“分支到构建”部分

job('example') {
  using('template_job')
  configure { node ->
    node / scm / branches / 'hudson.plugins.git.BranchSpec' {
      name 'branchname'
     }
  }
}
但现在我的模板作业有多个响应,我必须更改分支,以便使用配置块仅为其中一个存储库构建。我怎样才能做到这一点

我也尝试了下面的代码。它不工作,没有做任何更改。对这项工作有任何修改吗

 configure {node ->
    node / scm/ 'hudson.plugins.git.GitSCM'[1]  / branches / 'hudson.plugins.git.BranchSpec'{ 
    name branchName1
    };   
    }

/
运算符仅返回具有给定名称的第一个子项。您需要将中间节点分配给一个变量,然后使用
groovy.util.node
API访问任何子节点。从那时起,您可以使用
/
再次导航。下面的示例修改了第二个SCM配置,索引从零开始

job('example') {
  using('template')
  configure { node ->
    def scms = node / scm / scms
    scms.children()[1] / branches / 'hudson.plugins.git.BranchSpec'{ 
      name('foo')
    }
  }
}