summaryrefslogtreecommitdiff
path: root/Jenkinsfile
blob: 32ddcd65d3cd9ce2cbed408c31b3913f527199a5 (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
#!/usr/bin/env groovy

@NonCPS
def setDescription() {
    def item = Jenkins.instance.getItemByFullName(env.JOB_NAME)
    item.setDescription("VyOS image build using a\nPipeline build inside Docker container.")
    item.save()
}

setDescription()

/* Only keep the 10 most recent builds. */
def projectProperties = [
    [$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '5']],
]

properties(projectProperties)

pipeline {
    agent {
        dockerfile {
            filename 'Dockerfile'
            label 'jessie-amd64'
            dir 'docker'
            args '--privileged --sysctl net.ipv6.conf.lo.disable_ipv6=0 -e GOSU_UID=1006 -e GOSU_GID=1006'
        }
    }

    stages {
        stage('Submodule Init') {
            steps {
                sh '''
                    git submodule update --init --recursive
                    git submodule update --remote
                '''
            }
        }
        stage('Build Packages') {
            steps {
                sh 'scripts/build-submodules --verbose'
            }
        }
        stage('Build ISO') {
            steps {
                sh '''
                    #!/bin/sh
                    ./configure --build-by="autobuild@vyos.net" --debian-mirror="http://ftp.us.debian.org/debian/"
                    ls -al packages/*.deb
                    sudo make iso
                '''
            }
        }
    }

    post {
        always {
            echo 'One way or another, I have finished'
            // the 'build' directory got elevated permissions during the build
            // cdjust permissions so it can be cleaned up by the regular user
            sh 'sudo chmod -R 777 build/'
            deleteDir() /* cleanup our workspace */
        }
    }
}