Jenkins multibranch pipeline Scan without execution

前端 未结 4 2068
不思量自难忘°
不思量自难忘° 2021-02-06 22:04

Is it possible to Scan a Multibranch Pipeline to detect the branches with a Jenkinsfile, but without the pipeline execution?

My projects have different branc

4条回答
  •  滥情空心
    2021-02-06 22:39

    Also, you can do it programatically

    import jenkins.branch.*
    import jenkins.model.Jenkins
    
    
    for (f in Jenkins.instance.getAllItems(jenkins.branch.MultiBranchProject.class)) {
      if (f.parent instanceof jenkins.branch.OrganizationFolder) {
        continue;
      }
      for (s in f.sources) {
        def prop = new jenkins.branch.NoTriggerBranchProperty();
        def propList = [prop] as jenkins.branch.BranchProperty[];
        def strategy = new jenkins.branch.DefaultBranchPropertyStrategy(propList);
        s.setStrategy(strategy);
      }
    
      f.computation.run()
    }
    

    This is a Groovy snippet you can execute in Jenkins, it's gonna do the scanning but will not start new "builds" for all discovered branches.

提交回复
热议问题