You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2018/04/12 14:01:16 UTC

[sling-tooling-jenkins] branch master updated: SLING-7579 - Add support for building pipeline projects

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-tooling-jenkins.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a47ec4  SLING-7579 - Add support for building pipeline projects
1a47ec4 is described below

commit 1a47ec40b76dad475daf02c120ebb6cb448fca5f
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Apr 12 17:00:46 2018 +0300

    SLING-7579 - Add support for building pipeline projects
    
    Initial support for pipeline projects.
---
 create_jobs.groovy | 186 ++++++++++++++++++++++++++++++++---------------------
 1 file changed, 111 insertions(+), 75 deletions(-)

diff --git a/create_jobs.groovy b/create_jobs.groovy
index d86f61d..0582f2d 100644
--- a/create_jobs.groovy
+++ b/create_jobs.groovy
@@ -17,7 +17,17 @@ manifest.project.each { project ->
     } catch ( FileNotFoundException e) {
         println "${jobName}: no .sling-module.xml found, using defaults"
     }
+
     def module = [ location: jobName ]
+
+    try {
+        def connection = new URL(rawUrlPrefix + "/" + jobName + "/master/Jenkinsfile")
+        module.pipeline = connection.responseCode == 200
+        if ( module.pipeline ) {
+            println "${jobName}: Jenkinsfile found, creating pipeline job"
+        }
+    }
+
     if ( slingMod?.jenkins?.jdks ) {
         def jdks = []
         slingMod.jenkins.jdks.jdk.each { jdks.add it.text() }
@@ -79,108 +89,134 @@ def jdkMapping = [
 
 modules.each { module ->
 
-    def jdks = module.jdks ?: defaultJdks
-    def deploy = true
+    if ( module.pipeline ) {
+        multibranchPipelineJob(location) {
+            description('''
+    <p>This build was automatically generated and any manual edits will be lost.</p>
+    <p>See <a href="https://cwiki.apache.org/confluence/display/SLING/Sling+Jenkins+Setup">Sling Jenkins Setup</a>
+    for more details</p>''')
+            branchSources {
+                github {
+                    scanCredentialsId('rombert')
+                    repoOwner('apache')
+                    repository(location)
+                }
+            }
 
-    def downstreamProjects = module.downstream?: []
-    def downstreamEntries = modules.findAll { downstreamProjects.contains(it.location) }
-    def downstreamJobs = []
+            orphanedItemStrategy {
+                discardOldItems {
+                    numToKeep(15)
+                }
+            }
 
-    downstreamEntries.each { downstreamEntry ->
-        def downstreamJdks = downstreamEntry.jdks?: defaultJdks
-        def downstreamLocation = downstreamEntry.location
-        downstreamJdks.each { downstreamJdk ->
-            downstreamJobs.add(jobName(downstreamLocation,downstreamJdk))
+            triggers {
+                periodic(1)
+            }            
+        }
+    } else {
+        def jdks = module.jdks ?: defaultJdks
+        def deploy = true
+
+        def downstreamProjects = module.downstream?: []
+        def downstreamEntries = modules.findAll { downstreamProjects.contains(it.location) }
+        def downstreamJobs = []
+
+        downstreamEntries.each { downstreamEntry ->
+            def downstreamJdks = downstreamEntry.jdks?: defaultJdks
+            def downstreamLocation = downstreamEntry.location
+            downstreamJdks.each { downstreamJdk ->
+                downstreamJobs.add(jobName(downstreamLocation,downstreamJdk))
+            }
         }
-    }
 
-    jdks.each { jdkKey ->
-        mavenJob(jobName(module.location, jdkKey)) {
+        jdks.each { jdkKey ->
+            mavenJob(jobName(module.location, jdkKey)) {
 
-            description('''
-<p>This build was automatically generated and any manual edits will be lost.</p>
-<p>See <a href="https://cwiki.apache.org/confluence/display/SLING/Sling+Jenkins+Setup">Sling Jenkins Setup</a>
-for more details</p>''')
+                description('''
+    <p>This build was automatically generated and any manual edits will be lost.</p>
+    <p>See <a href="https://cwiki.apache.org/confluence/display/SLING/Sling+Jenkins+Setup">Sling Jenkins Setup</a>
+    for more details</p>''')
 
-            logRotator {
-                numToKeep(15)
-            }
+                logRotator {
+                    numToKeep(15)
+                }
 
-            scm {
-                git {
-                    remote {
-                        github('apache/' + module.location)
+                scm {
+                    git {
+                        remote {
+                            github('apache/' + module.location)
+                        }
+                        branches('master')
                     }
-                    branches('master')
                 }
-            }
-
-            blockOnUpstreamProjects()
 
-            triggers {
-                snapshotDependencies(true)
-                scm('H/15 * * * *')
-                def rebuildFrequency = module.rebuildFrequency ? module.rebuildFrequency : '@weekly'
-                cron(rebuildFrequency)
-            }
+                blockOnUpstreamProjects()
 
-            // timeout if the job takes 4 times longer than the average
-            // duration of the last 3 jobs. Defaults to 30 minutes if
-            // no previous job executions are found
-            wrappers {
-                timeout {
-                    elastic(400, 3, 30)
+                triggers {
+                    snapshotDependencies(true)
+                    scm('H/15 * * * *')
+                    def rebuildFrequency = module.rebuildFrequency ? module.rebuildFrequency : '@weekly'
+                    cron(rebuildFrequency)
                 }
 
-                if ( module.enableXvfb ) {
-                    xvfb('Xvfb')
+                // timeout if the job takes 4 times longer than the average
+                // duration of the last 3 jobs. Defaults to 30 minutes if
+                // no previous job executions are found
+                wrappers {
+                    timeout {
+                        elastic(400, 3, 30)
+                    }
+
+                    if ( module.enableXvfb ) {
+                        xvfb('Xvfb')
+                    }
                 }
-            }
 
-            blockOnUpstreamProjects()
+                blockOnUpstreamProjects()
 
-            jdk(jdkMapping.get(jdkKey))
+                jdk(jdkMapping.get(jdkKey))
 
-            mavenInstallation(defaultMvn)
+                mavenInstallation(defaultMvn)
 
-            // we have no use for archived artifacts since they are deployed on
-            // repository.apache.org so speed up the build a bit (and probably
-            // save on disk space)
-            archivingDisabled(true)
+                // we have no use for archived artifacts since they are deployed on
+                // repository.apache.org so speed up the build a bit (and probably
+                // save on disk space)
+                archivingDisabled(true)
 
-            label(defaultSlave)
+                label(defaultSlave)
 
-            // ensure that only one job deploys artifacts
-            // besides being less efficient, it's not sure which
-            // job is triggered first and we may end up with a
-            // mix of Java 7 and Java 8 artifacts for projects which
-            // use these 2 versions
-            def extraGoalsParams = module.extraGoalsParams ?: ""
-            def goal = module.mavenGoal ? module.mavenGoal : ( deploy ? "deploy" : "verify" )
-            goals( "-U clean ${goal} ${extraGoalsParams}")
+                // ensure that only one job deploys artifacts
+                // besides being less efficient, it's not sure which
+                // job is triggered first and we may end up with a
+                // mix of Java 7 and Java 8 artifacts for projects which
+                // use these 2 versions
+                def extraGoalsParams = module.extraGoalsParams ?: ""
+                def goal = module.mavenGoal ? module.mavenGoal : ( deploy ? "deploy" : "verify" )
+                goals( "-U clean ${goal} ${extraGoalsParams}")
 
-            publishers {
-                if ( deploy && downstreamJobs ) {
-                    downstream(downstreamJobs)
-                }
+                publishers {
+                    if ( deploy && downstreamJobs ) {
+                        downstream(downstreamJobs)
+                    }
 
-                if (module.archivePatterns) {
-                    archiveArtifacts() {
-                        module.archivePatterns.each { archiveEntry ->
-                            pattern(archiveEntry)
+                    if (module.archivePatterns) {
+                        archiveArtifacts() {
+                            module.archivePatterns.each { archiveEntry ->
+                                pattern(archiveEntry)
+                            }
                         }
                     }
-                }
 
-                // TODO - can we remove the glob and rely on the defaults?
-                archiveJunit('**/target/surefire-reports/*.xml,**/target/failsafe-reports/*.xml') {
-                    allowEmptyResults()
+                    // TODO - can we remove the glob and rely on the defaults?
+                    archiveJunit('**/target/surefire-reports/*.xml,**/target/failsafe-reports/*.xml') {
+                        allowEmptyResults()
+                    }
+                    // send emails for each broken build, notify individuals as well
+                    mailer('commits@sling.apache.org', false, true)
                 }
-                // send emails for each broken build, notify individuals as well
-                mailer('commits@sling.apache.org', false, true)
-            }
 
-            deploy = false
+                deploy = false
+            }
         }
     }
 }

-- 
To stop receiving notification emails like this one, please contact
rombert@apache.org.