Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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
带回退的Jenkins Git分支选择_Git_Github_Jenkins_Bitbucket_Jenkins Plugins - Fatal编程技术网

带回退的Jenkins Git分支选择

带回退的Jenkins Git分支选择,git,github,jenkins,bitbucket,jenkins-plugins,Git,Github,Jenkins,Bitbucket,Jenkins Plugins,在我的项目中,我有一个样式库 我怎样才能让詹金斯做到以下几点:(XXXX=发布号) 构建发布XXXX分支 如果发布分支不存在,则生成主分支 我知道我可以使用插件将分支按优先级排序,但我不知道如何选择包含单词Release的分支-您可以使用管道来实现这一点 def doCheckout(cloneUrl,branches) { for (String branch : branches) { try { deleteDir() sh 'git config --global cr

在我的项目中,我有一个样式库

我怎样才能让詹金斯做到以下几点:(XXXX=发布号)

  • 构建发布XXXX分支
  • 如果发布分支不存在,则生成主分支

  • 我知道我可以使用插件将分支按优先级排序,但我不知道如何选择包含单词Release的分支-

    您可以使用管道来实现这一点

    def doCheckout(cloneUrl,branches) {
     for (String branch : branches) {
      try {
       deleteDir()
       sh 'git config --global credential.helper cache'
       checkout([
        $class: 'GitSCM',
        branches: [[name: branch]],
        extensions: [
         [$class: 'CloneOption',
          noTags: false,
          reference: '',
          shallow: true,
          honorRefspec: true],
         [$class: 'WipeWorkspace'],
         [$class: 'CleanBeforeCheckout']
        ],
        submoduleCfg: [],
        userRemoteConfigs: [
         [ credentialsId: 'someCredentialId', url: cloneUrl]
        ]
       ])
       sh "git checkout ${branch}"
       return
      } catch (Throwable throwable) {
       //Try next...
      }
     }
     throw new RuntimeException("Could not find any of the ${branches} from ${cloneUrl}")
    }
    
    def branches = ['release','develop','master']
    doCheckout(cloneUrl, branches)
    

    嗨,我也有同样的问题,但我需要一个声明性管道的解决方案。有人能帮我吗?