Jenkins使用DSL将git子模块添加到multibranchPipelineJob

莫·拉伊卜

我有一个DSL脚本来创建我的Jenkins管道作业。

String[] repos =
    ['xxx']    

for (int i = 0; i < repos.length; i++) {
    repoName = repos[i];    
    multibranchPipelineJob('PIPELINE-'+repoName) {
        branchSources {
            git {
                remote('[email protected]:yyy/'+repoName+'.git')
                credentialsId('112233445566')
            }
        }
        description ("""<p> <b>generate by DSL - DO NOT CHANGE Manually </b> <p>""")
        triggers {
            periodic(2)
        }
        orphanedItemStrategy {
            discardOldItems {
                numToKeep(0)
                daysToKeep(0)
            }
        }
    }
}

我要添加其他行为-高级子模块行为在此处输入图片说明

这是一个添加子模块标签和分支发现的脚本

multibranchPipelineJob('example') {
  branchSources {    
    branchSource {
      source {        
        git {
          credentialsId('1111-2222-3333')
          remote('[email protected]:xxx/yyyy.git')

          traits {            
            submoduleOptionTrait {
              extension {
                disableSubmodules(false)
                recursiveSubmodules(true)
                trackingSubmodules(false)
                reference(null)
                timeout(null)
                parentCredentials(true)
              }
            }

            cloneOptionTrait {
              extension {
                shallow (false)
                noTags (false)
                reference (null)
                depth(0)
                honorRefspec (false)
                timeout (10)
              }
            }
          }
        }
      }
    } 
  }

  triggers {
            periodic(2)
        }

configure {
      def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
      traits << 'jenkins.plugins.git.traits.BranchDiscoveryTrait' {}
    }  
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Git递归地将遥控器添加到子模块

无法将子模块添加到android项目

将子模块添加到存储库

将子模块的寄存器添加到新/实例化它的模块的 regmap()

将 Maven 子模块添加到 IntelliJ 中的父模块

Git子模块添加到现有的非空文件夹

将子模块中的小程序添加到Maven中的WAR文件

将链接添加到推送存储库中的子模块

如何将子模块添加到github存储库

如何将远程子模块添加到我的github项目中?

将子模块文件永久添加到主存储库

如何将现有的嵌套存储库(已在子目录中签出)添加到父Git存储库作为子模块?

将现有的未版本化目录作为 git 子模块添加到位(同时尽可能避免移动和复制)

有没有一种方法可以将子模块添加到共享目录结构的git repo中

使用Java从Jmeter将Assertion模块添加到HashTree

如何使用CLI将模块添加到Wildfly

使用Jenkins将.net核心添加到Docker容器

将模块添加到AAR

将模块目录添加到@INC

将LUA模块添加到Nginx

将标签添加到扩展/模块

使用IntelliJ IDEA将文件添加到Git

将Simperium模块添加到项目中会导致未找到Gradle DSL方法:“ gitVersion()”错误

使用特定的提交编号添加git子模块

由于Windows上的长路径错误,无法将节点js模块添加到git中

将文件添加到Kotlin DSL中的Gradle sourceSets

尝试将Git存储库添加到Jenkins时的访问问题

如何将子模块添加到现有仓库中,在本地进行更改,然后将所有更改推送到github?

将文件添加到git确认