You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2022/10/10 13:32:25 UTC

[sling-tooling-jenkins] 01/01: SLING-11396 configurable operating system with matrix builds

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

kwin pushed a commit to branch feature/configurable-os
in repository https://gitbox.apache.org/repos/asf/sling-tooling-jenkins.git

commit 67faaa9ce23c9c4ab761b8ae0560817adbd69c0b
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Oct 10 15:32:20 2022 +0200

    SLING-11396 configurable operating system with matrix builds
---
 vars/slingOsgiBundleBuild.groovy | 45 ++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/vars/slingOsgiBundleBuild.groovy b/vars/slingOsgiBundleBuild.groovy
index 252404b..a05572e 100644
--- a/vars/slingOsgiBundleBuild.groovy
+++ b/vars/slingOsgiBundleBuild.groovy
@@ -3,14 +3,18 @@ import org.apache.sling.jenkins.SlingJenkinsHelper;
 def call(Map params = [:]) {
 
     def globalConfig = [
-        availableJDKs : [ 8: 'jdk_1.8_latest', 9: 'jdk_1.9_latest', 10: 'jdk_10_latest', 11: 'jdk_11_latest', 12: 'jdk_12_latest', 13: 'jdk_13_latest', 14: 'jdk_14_latest', 15: 'jdk_15_latest', 16: 'jdk_16_latest', 17: 'jdk_17_latest', 18: 'jdk_18_latest'],
-        mvnVersion : 'maven_3_latest',
-        mainNodeLabel : 'ubuntu',
+        availableJDKs : [ 8: 'jdk_1.8_latest', 9: 'jdk_1.9_latest', 10: 'jdk_10_latest', 11: 'jdk_11_latest',
+                          12: 'jdk_12_latest', 13: 'jdk_13_latest', 14: 'jdk_14_latest', 15: 'jdk_15_latest',
+                          16: 'jdk_16_latest', 17: 'jdk_17_latest', 18: 'jdk_18_latest', 19: 'jdk_19_latest'],
+        mvnVersion : 'maven_3_latest'
+        // maps values to node labels (available ones in https://cwiki.apache.org/confluence/display/INFRA/ci-builds.apache.org)
+        availableOperatingSystems : ['windows' : 'Windows', 'linux': 'ubuntu', 'linux-arm': 'arm', 'ubuntu': 'ubuntu']
         githubCredentialsId: 'sling-github-token'
     ]
 
     def jobConfig = [
         jdks: [8],
+        operatingSystems: ['linux']
         upstreamProjects: [],
         archivePatterns: [],
         mavenGoal: '',
@@ -74,13 +78,15 @@ def call(Map params = [:]) {
             def referenceJdkVersion
             // parallel execution of all build jobs
             jobConfig.jdks.each { jdkVersion -> 
-                stageDefinition = defineStage(globalConfig, jobConfig, jdkVersion, isReferenceStage, shouldDeploy)
-                if ( isReferenceStage ) {
-                    referenceJdkVersion = jdkVersion
+                jobConfig.operatinSystems.each { operatingSystem ->
+                    stageDefinition = defineStage(globalConfig, jobConfig, jdkVersion, operatingSystem, isReferenceStage, shouldDeploy)
+                    if ( isReferenceStage ) {
+                        referenceJdkVersion = jdkVersion
+                    }
+                    stepsMap["Build (Java ${jdkVersion} on ${operatingSystem})"] = stageDefinition
+                    isReferenceStage = false
+                    currentBuild.result = "SUCCESS"
                 }
-                stepsMap["Build (Java ${jdkVersion})"] = stageDefinition
-                isReferenceStage = false
-                currentBuild.result = "SUCCESS"
             }
 
             // do a quick sanity check first without tests if multiple parallel builds are required
@@ -122,13 +128,27 @@ def jenkinsJdkLabel(int jdkVersion, def globalConfig) {
     return label
 }
 
+def jenkinsNodeLabel(String operatingSystem, def jobConfig, def globalConfig) {
+    def branchConfig = jobConfig?.branches?."$env.BRANCH_NAME" ?: [:]
+    if ( branchConfig.nodeLabel ) {
+        echo "Using branch specific node label ${branchConfig.nodeLabel}"
+        return label
+    } else {
+        def label = globalConfig.availableOperatingSystems[operatingSystem]
+        if ( !label )
+            error("Unknown operating system ${operatingSystem}. Available operating systems: ${globalConfig.availableOperatingSystems}")
+        echo "Using operating-system ${operatingSystem} specific node label ${label}"
+        return label
+    }
+}
+
 def additionalMavenParams(def jobConfig) {
     def branchConfig = jobConfig?.branches?."$env.BRANCH_NAME" ?: [:]
     return branchConfig.additionalMavenParams ?
         branchConfig.additionalMavenParams : jobConfig.additionalMavenParams
 }
 
-def defineStage(def globalConfig, def jobConfig, def jdkVersion, boolean isReferenceStage, boolean shouldDeploy) {
+def defineStage(def globalConfig, def jobConfig, def jdkVersion, def operatingSystem, boolean isReferenceStage, boolean shouldDeploy) {
 
     def goal = jobConfig.mavenGoal ? jobConfig.mavenGoal : ( isReferenceStage ? "deploy" : "verify" )
     def additionalMavenParams = additionalMavenParams(jobConfig)
@@ -177,10 +197,9 @@ def defineStage(def globalConfig, def jobConfig, def jdkVersion, boolean isRefer
         }
     }
     
-    def branchConfig = jobConfig?.branches?."$env.BRANCH_NAME" ?: [:]
-
+    def jenkinsNodeLabel = jenkinsNodeLabel(operatingSystem, jobConfig, globalConfig)
     return {
-        node(branchConfig.nodeLabel ?: globalConfig.mainNodeLabel) {
+        node(jenkinsNodeLabel) {
             dir(jenkinsJdkLabel) { // isolate parallel builds on same node
                 timeout(time: 30, unit: 'MINUTES') {
                     checkout scm