blob: 78cb50940e63a8789d92db8a408d295569e6b970 [file] [log] [blame]
#!/usr/bin/env groovy
library 'functions'
def workspacePath = "/home/jenkins/agent/workspace"
def buildLabel = "task.publish.unstable-${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,
alwaysPullImage: true)
def aptlyVolume = persistentVolumeClaim(claimName: 'aptly-state', mountPath: '/var/lib/aptly')
def gpgVolume = secretVolume(secretName: 'mendel-release-credentials', mountPath: '/var/lib/aptly/keyring')
podTemplate(label: buildLabel, containers: [jnlpContainer, debianContainer], volumes: [aptlyVolume, gpgVolume], envVars: []) {
node(buildLabel) {
dir(sourcePath) {
container('debian') {
String stamp = functions.generateDateStamp()
def releaseName = params.release
def boards = params.boards.split(' ')
if (boards.size() == 0) {
error 'No boards to create releases for!'
}
sh "cp /etc/aptly.conf ~/.aptly.conf"
withEnv(['GNUPGHOME=/var/lib/aptly/.gnupg']) {
functions.installGpgKeyring()
for (board in boards) {
def unstablePublishedBspSnapshotName = functions.getSnapshotFromPublish('unstable', "unstable-bsp-${board}", 'main')
def releasedBspSnapshotName = "${releaseName}-bsp-${board}-${stamp}"
sh "aptly snapshot merge ${releasedBspSnapshotName} ${unstablePublishedBspSnapshotName}"
if (functions.bspIsPublished(releaseName, board)) {
sh "aptly publish switch --batch --force-overwrite --passphrase-file=/var/lib/aptly/keyring/passphrase.txt ${releaseName} filesystem:public:${releaseName}-bsp-${board} ${releasedBspSnapshotName}"
} else {
sh "aptly publish snapshot --batch --force-overwrite --passphrase-file=/var/lib/aptly/keyring/passphrase.txt --architectures=source,amd64,arm64,armhf --distribution=${releaseName} ${releasedBspSnapshotName} filesystem:public:${releaseName}-bsp-${board}"
}
}
def unstablePublishedCoreSnapshotName = functions.getSnapshotFromPublish('unstable', 'unstable', 'main')
def releasedCoreSnapshotName = "core-full-${releaseName}-${stamp}"
sh "aptly snapshot merge ${releasedCoreSnapshotName} ${unstablePublishedCoreSnapshotName}"
if (functions.coreIsPublished(releaseName)) {
sh "aptly publish switch --batch --force-overwrite --passphrase-file=/var/lib/aptly/keyring/passphrase.txt ${releaseName} filesystem:public:${releaseName} ${releasedCoreSnapshotName}"
} else {
sh "aptly publish snapshot --batch --force-overwrite --passphrase-file=/var/lib/aptly/keyring/passphrase.txt --architectures=source,amd64,arm64,armhf --distribution=${releaseName} ${releasedCoreSnapshotName} filesystem:public:${releaseName}"
}
}
}
}
}
}