| #!/usr/bin/env groovy |
| |
| library 'functions' |
| |
| def workspacePath = "/home/jenkins/workspace" |
| def buildLabel = "image.unstable.enterprise-${UUID.randomUUID().toString()}" |
| def sourcePath = "${workspacePath}/src" |
| |
| // FIXME(jtgans): Get rid of privileged! This is a security risk! |
| def jnlpContainer = containerTemplate(name: 'jnlp', |
| image: 'jenkins/jnlp-slave:alpine') |
| def debianContainer = containerTemplate(name: 'debian', |
| image: 'gcr.io/mendel-linux-cloud-infra/mendel-builder:latest', |
| command: 'cat', |
| args: '', |
| ttyEnabled: true, |
| privileged: true) |
| def aptlyVolume = persistentVolumeClaim(claimName: 'aptly-state', mountPath: '/var/lib/aptly') |
| def envVars = [ |
| 'IS_JENKINS=true', |
| 'RELEASE_NAME=unstable' |
| ] |
| |
| podTemplate(label: buildLabel, containers: [jnlpContainer, debianContainer], volumes: [aptlyVolume], envVars: envVars) { |
| node(buildLabel) { |
| dir(sourcePath) { |
| container('debian') { |
| stage('Init') { |
| functions.initSourceTree(boardName, false /* needsNative */) |
| } |
| |
| stage('Build') { |
| def nprocs = sh(returnStdout: true, script: 'nproc').trim() |
| sh "bash -c 'source build/setup.sh; m -j${nprocs} prereqs dist; exit \$?'" |
| } |
| |
| stage('Deploy') { |
| def imagePath = "/var/lib/aptly/images/enterprise/unstable" |
| def files = findFiles(glob: "out/**/dist/*") |
| |
| if (files.size() == 0) { |
| error 'No dist files generated. Assuming failed build.' |
| } |
| |
| sh "mkdir -p ${imagePath}" |
| |
| for (file in files) { |
| sh "cp ${file} ${imagePath}" |
| } |
| } |
| } |
| } |
| } |
| } |