mirrors: Make a task to create a new mirror
We'll need this as we go on, but this effectively creates a task that can be
used to create new mirrors of upstream Debian sources with a nice parameterized
UI to it.
Change-Id: I61d106b294795d2b265e2599e27fd25047231c3c
diff --git a/cicd/jobs/task_create_mirror.jenkins b/cicd/jobs/task_create_mirror.jenkins
new file mode 100644
index 0000000..3b47619
--- /dev/null
+++ b/cicd/jobs/task_create_mirror.jenkins
@@ -0,0 +1,32 @@
+#!/usr/bin/env groovy
+
+pipelineJob("task.mirror.create") {
+ description("Create a new apt mirror")
+
+ parameters {
+ stringParam(name: 'name',
+ description: 'The name of the mirror to create')
+ stringParam(name: 'url',
+ description: 'The URL of the apt source to mirror')
+ stringParam(name: 'components',
+ description: 'A space separated list of components to mirror')
+ stringParam(name: 'architectures',
+ defaultValue: 'armhf,arm64,amd64,all',
+ description: 'A comma separated list of architectures to mirror')
+ }
+
+ definition {
+ cpsScm {
+ scm {
+ git {
+ remote {
+ url('https://coral.googlesource.com/gke-jenkins')
+ }
+ branches('*/master')
+ }
+ }
+
+ scriptPath("cicd/pipelines/tasks/task_create_mirror.jenkins")
+ }
+ }
+}
diff --git a/cicd/pipelines/tasks/task_create_mirror.jenkins b/cicd/pipelines/tasks/task_create_mirror.jenkins
new file mode 100644
index 0000000..251293f
--- /dev/null
+++ b/cicd/pipelines/tasks/task_create_mirror.jenkins
@@ -0,0 +1,35 @@
+#!/usr/bin/env groovy
+
+def workspacePath = "/home/jenkins/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') {
+ sh "aptly mirror list -raw"
+
+ stage('Mirror') {
+ sh """
+ aptly mirror create ${params.name} ${params.url} ${params.components} -architectures="${params.architectures}"
+ """
+ }
+ }
+ }
+ }
+}