| #!/usr/bin/env groovy |
| |
| def workspacePath = "/home/jenkins/agent/workspace" |
| def buildLabel = "task.mirror.create-${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') |
| |
| podTemplate(label: buildLabel, containers: [jnlpContainer, debianContainer], volumes: [aptlyVolume], envVars: []) { |
| def date = new Date() |
| String stamp = date.format("yyyyMMdd-HHmmss") |
| |
| node(buildLabel) { |
| dir(sourcePath) { |
| container('debian') { |
| withEnv(['GNUPGHOME=/var/lib/aptly/.gnupg']) { |
| stage('Keys') { |
| if (params.keys.size() > 0) { |
| sh """ |
| env |
| gpg --no-default-keyring \ |
| --keyring trustedkeys.gpg \ |
| --keyserver pool.sks-keyservers.net \ |
| --recv-keys ${params.keys} |
| """ |
| } |
| } |
| |
| stage('Mirror') { |
| sh """ |
| aptly -architectures="${params.architectures}" mirror create ${params.name} ${params.url} ${params.release} ${params.components} |
| """ |
| } |
| } |
| } |
| } |
| } |
| } |