summaryrefslogtreecommitdiff
path: root/Jenkinsfile
blob: 10e0f32174dd87519e4c96b02cb5960f74b2c50d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env groovy

node('master') {
    checkout scm
    passedBuilds = []
    def changelog = lastSuccessfulBuild(passedBuilds, currentBuild)

    slackSend "Building ${env.JOB_NAME} #${env.BUILD_NUMBER} \n ${changelog}"
}

parallel 'centos7': {
    node('centos7') {
        try {
            checkout scm

	        stage('Build Centos 7') {
                sh 'make -f make-linux.mk'
            }
        }
        catch (err) {
            currentBuild.result = "FAILURE"
            slackSend 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-r13/ndk-build -C $WORKSPACE/java ZT1=${WORKSPACE}"
            }
        }
        catch (err) {
            currentBuild.result = "FAILURE"
            slackSend 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'
            }

            stage('Build macOS UI') {
                sh 'cd macui && xcodebuild -target "ZeroTier One" -configuration Debug'
            }
        }
        catch (err) {
            currentBuild.result = "FAILURE"
            slackSend color: '#ff0000', message: "${env.JOB_NAME} broken on macOS (<${env.BUILD_URL}|Open>)"

            throw err
        }
    }
}

slackSend "${env.JOB_NAME} #${env.BUILD_NUMBER} Complete (<${env.BUILD_URL}|Show More...>)"

def lastSuccessfulBuild(passedBuilds, build) {
  if ((build != null) && (build.result != 'SUCCESS')) {
      passedBuilds.add(build)
      lastSuccessfulBuild(passedBuilds, build.getPreviousBuild())
   }
}

@NonCPS
def getChangeLog(passedBuilds) {
    def log = ""
    for (int x = 0; x < passedBuilds.size(); x++) {
        def currentBuild = passedBuilds[x];
        def changeLogSets = currentBuild.rawBuild.changeSets
        for (int i = 0; i < changeLogSets.size(); i++) {
            def entries = changeLogSets[i].items
            for (int j = 0; j < entries.length; j++) {
                def entry = entries[j]
                log += "* ${entry.msg} by ${entry.author} \n"
            }
        }
    }
    return log;
}