Browse Source

Update to jenkinsfile for multi-platform release builds

Grant Limberg 5 years ago
parent
commit
0f17cd4791
1 changed files with 37 additions and 66 deletions
  1. 37 66
      Jenkinsfile

+ 37 - 66
Jenkinsfile

@@ -1,83 +1,54 @@
 #!/usr/bin/env groovy
-
-node('master') {
-    checkout scm
-    
-    def changelog = getChangeLog currentBuild
-
-    mattermostSend "Building ${env.JOB_NAME} #${env.BUILD_NUMBER} \n Change Log: \n ${changelog}"
+options {
+    disableConcurrentBuilds()
 }
 
-parallel 'centos7': {
-    node('centos7') {
-        try {
+def alpineStaticTask(distro, platform) {
+    def myNode = {
+        node ('linux-build') {
             checkout scm
-
-	        stage('Build Centos 7') {
-                sh 'make -f make-linux.mk'
+            def runtime = docker.image("ztbuild/${distro}-${platform}:latest")
+            runtime.inside {
+                sh 'make -j8 ZT_STATIC=1 all'
+                sh "mv zerotier-one zerotier-one-static-${platform}"
+                archiveArtifacts artifacts: 'zerotier-one-*', fingerprint: true, onlyIfSuccessful: true
             }
         }
-        catch (err) {
-            currentBuild.result = "FAILURE"
-            mattermostSend color: '#ff0000', message: "${env.JOB_NAME} broken on Centos 7 (<${env.BUILD_URL}|Open>)"
-
-            throw err
-        }
     }
-// }, 'android-ndk': {
-//     node('android-ndk') {
-//         try {
-//             checkout scm
-	
-//             stage('Build Android NDK') { 
-//                 sh "/android/android-ndk-r15b/ndk-build -C $WORKSPACE/java ZT1=${WORKSPACE}"
-//             }
-//         }
-//         catch (err) {
-//             currentBuild.result = "FAILURE"
-//             mattermostSend color: '#ff0000', message: "${env.JOB_NAME} broken on Android NDK (<${env.BUILD_URL}|Open>)"
-
-//             throw err
-//         }
-//     }
-}, 'macOS': {
-    node('macOS') {
-        try {
-            checkout scm
-
-            stage('Build macOS') {
-                sh 'make -f make-mac.mk'
-            }
+    return myNode
+}
 
-            stage('Build macOS UI') {
-                sh 'cd macui && xcodebuild -target "ZeroTier One" -configuration Debug'
-            }
+def getTasks(axisDistro, axisPlatform, task) {
+    def tasks = [:]
+    for(int i=0; i< axisDistro.size(); i++) {
+        def axisDistroValue = axisDistro[i]
+        for(int j=0; j< axisPlatform.size(); j++) {
+            def axisPlatformValue = axisPlatform[j]
+            tasks["${axisDistroValue}/${axisPlatformValue}"] = task(axisDistroValue, axisPlatformValue)
         }
-        catch (err) {
-            currentBuild.result = "FAILURE"
-            mattermostSend color: '#ff0000', message: "${env.JOB_NAME} broken on macOS (<${env.BUILD_URL}|Open>)"
+    }
+    return tasks
+}
 
-            throw err
-        }
+pipeline {
+    options {
+        disableConcurrentBuilds()
     }
-}, 'windows': {
-    node('windows') {
-        try {
-            checkout scm
-            
-            stage('Build Windows') {
-                bat '''CALL "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvars32.bat" x64
-msbuild windows\\ZeroTierOne.sln
-'''
+    
+    agent none
+    
+    stages {
+        stage ("Static Build") {
+            steps {
+                script {
+                    def dist = ["alpine"]
+                    def archs = ["aarch64", "amd64", "i386", "armhf", "armel", "ppc64le", "s390x"]
+                    parallel getTasks(dist, archs, this.&alpineStaticTask)
+                }
             }
         }
-        catch (err) {
-            currentBuild.result = "FAILURE"
-            mattermostSend color: '#ff0000', message: "${env.JOB_NAME} broken on Windows (<${env.BUILD_URL}|Open>)"
-
-            throw err
-        }
     }
 }
 
+
 mattermostSend color: "#00ff00", message: "${env.JOB_NAME} #${env.BUILD_NUMBER} Complete (<${env.BUILD_URL}|Show More...>)"