ci: Add Jenkins build pipeline
ContainerImages/gasket-driver/pipeline/head There was a failure building this commit Details

This Jenkins pipeline runs every day and fetches the latest FCOS
metadata to determine if a new version of the kernel driver needs to be
built.  If no container image matching the kernel version in the latest
FCOS release exists, it will be built and pushed to the image
repository.
master
Dustin 2024-01-06 11:30:19 -06:00
parent 3c9c274773
commit f02b02bea0
1 changed files with 62 additions and 0 deletions

62
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,62 @@
// vim: set sw=4 ts=4 sts=4 et :
properties([
pipelineTriggers([cron('H H * * *')])
])
import groovy.json.JsonSlurper
def get_fcos_release(arch) {
def res = httpRequest(
url: 'https://builds.coreos.fedoraproject.org/streams/stable.json',
acceptType: 'APPLICATION_JSON',
)
def json = new JsonSlurper()
def data = json.parseText(res.getContent())
return data.architectures[arch].artifacts.metal.release
}
def get_kernel_version(arch, fcos_release) {
def res = httpRequest(
url: "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/${fcos_release}/${arch}/commitmeta.json",
acceptType: 'APPLICATION_JSON',
)
def json = new JsonSlurper()
def data = json.parseText(res.getContent())
def pkg = data["rpmostree.rpmdb.pkglist"].find { it.getAt(0) == "kernel" }
return "${pkg[2]}-${pkg[3]}.${pkg[4]}"
}
def check_container_image(kver) {
def res = httpRequest(
url: "https://git.pyrocufflink.net/ContainerImages/-/packages/container/gasket-driver/${kver}",
httpMode: 'HEAD',
validResponseCodes: '100:599',
)
return res.getStatus() < 300
}
def arch = 'x86_64'
def fcos_release = get_fcos_release(arch)
def kver = get_kernel_version(arch, fcos_release)
def fedora = (kver =~ /\.fc([0-9]+)\./)[0][1]
def registry = 'git.pyrocufflink.net'
def full_name = "${registry}/containerimages/gasket-driver:${kver}"
if (!check_container_image(kver)) {
buildContainerImage2.runInPod {
container('buildah') {
buildContainerImage2.withBuildahCreds(registry) {
stage('Build') {
checkout scm
sh "buildah build -t '${full_name}' --build-arg FEDORA='${fedora}' --build-arg KVER='${kver}'"
}
stage('Push') {
sh "buildah push '${full_name}'"
}
}
}
}
} else {
currentBuild.result = 'NOT_BUILT'
}