63 lines
1.9 KiB
Groovy
63 lines
1.9 KiB
Groovy
// 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'
|
|
}
|