attempts to switch to declarative format

This commit is contained in:
Hyatt 2022-04-01 17:21:47 -05:00
parent 80d76cdf55
commit 9e3bef91f0
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

View File

@ -3,27 +3,42 @@
def repository = "registry.c.test-chamber-13.lan" def repository = "registry.c.test-chamber-13.lan"
def repositoryCreds = "harbor-repository-creds" def repositoryCreds = "harbor-repository-creds"
def ubiOS = ["8"] def workspace
def ubiImages = ["ubi-minimal", "ubi"] def dockerFile
def ubiOS
def ubiImages
def label = "kubernetes-${UUID.randomUUID().toString()}" def label = "kubernetes-${UUID.randomUUID().toString()}"
def templateName = "pipeline-worker" def templateName = "pipeline-worker"
podTemplate ( pipeline {
label: label, agent {
name: templateName, kubernetes {
yaml: functions.podYaml( yaml functions.podYaml(
repo: repository, repo: repository,
templateName: templateName, templateName: templateName,
kaniko: true kaniko: true
) )
){ }
node (label) { }
def workspace = pwd()
stages {
stage ('Initalize Jenkins') {
steps {
script {
workspace = pwd()
ubiOS = ["8"]
ubiImages = ["ubi-minimal", "ubi"]
writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getLocalRootCA()) writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getLocalRootCA())
}
}
}
for (rhOS in ubiOS) { for (rhOS in ubiOS) {
for (image in ubiImages) { for (image in ubiImages) {
stage ("Build ubi${rhOS}:${image}") {
steps {
script {
def updateCmd def updateCmd
if (image == "ubi-minimal") { if (image == "ubi-minimal") {
updateCmd = "microdnf" updateCmd = "microdnf"
@ -32,7 +47,10 @@ podTemplate (
} }
def dockerFile = """FROM registry.access.redhat.com/ubi${rhOS}/${image}:latest def dockerFile = """FROM registry.access.redhat.com/ubi${rhOS}/${image}:latest
LABEL maintainer="The_Spider <spider@smoothnet.org>" LABEL org.opencontainers.image.authors="The_Spider <spider@smoothnet.org>"
LABEL org.opencontainers.image.title="ubi${rhOS}/${image}"
LABEL org.opencontainers.image.description="Docker container for RHEL-UBI"
LABEL org.opencontainers.image.base.name="registry.access.redhat.com/ubi${rhOS}/${image}:latest"
COPY test-chamber-13.lan.root.crt /etc/pki/ca-trust/source/anchors/test-chamber-13.lan.root.crt COPY test-chamber-13.lan.root.crt /etc/pki/ca-trust/source/anchors/test-chamber-13.lan.root.crt
@ -40,14 +58,24 @@ RUN update-ca-trust extract && \\
${updateCmd} update -y && \\ ${updateCmd} update -y && \\
${updateCmd} clean all ${updateCmd} clean all
""" """
container ("kaniko") {
functions.buildContainer( declarativeFunctions.buildContainerMultipleDestinations(
repository: repository,
imageDest: "${repository}/library/rhubi/${image}:${rhOS}",
dockerFile: dockerFile, dockerFile: dockerFile,
repoCreds: repositoryCreds, repositoryAccess: [
[
repository: repository,
credentials: repositoryCreds
],
],
destination: [
"${repository}/library/rhubi/${image}:${rhOS}",
]
) )
} }
} }
} }
} }
}
}
}
}