Преглед на файлове

Switch to Multibranch pipeline

seb преди 8 години
родител
ревизия
6c77cfccfd
променени са 1 файла, в които са добавени 11 реда и са изтрити 20 реда
  1. 11 20
      seedGogsProjects.groovy

+ 11 - 20
seedGogsProjects.groovy

@@ -25,30 +25,21 @@ projects.each {
   def jenkinsFile = restExists("${api}/repos/${project}/raw/master/Jenkinsfile?token=${apikey}")
   def jobName = "${JOB_PREFIX}${project}".replaceAll('/','-')
   if (jenkinsFile) {
-    pipelineJob(jobName) {
+    multibranchPipelineJob(jobName) {
+      description("Pipeline for $repo")
       triggers {
-        scm('@hourly')
+        cron('@hourly')
       }
-      description("Pipeline for $repo")
-      quietPeriod(5*60)
-      environmentVariables(FOO: 'bar', TEST: '123')
-      definition {
-        cpsScm {
-          scm {
-            git {
-              remote { 
-                url(repo) 
-                credentials(GOGS_CREDENTIALS)
-              }
-              branches('master', '**/feature*')
-              scriptPath('Jenkinsfile')
-              extensions { }  // required as otherwise it may try to tag the repo, which you may not want
-            }
-          }
+      branchSources {
+        git {
+          remote(repo)
+          credentialsId(GOGS_CREDENTIALS)
         }
       }
-      wrappers {
-        buildName('#${BUILD_NUMBER} on ${ENV,var="BRANCH"}')
+      orphanedItemStrategy {
+        discardOldItems {
+          numToKeep(10)
+        }
       }
     }
   }