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,36 +3,54 @@
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()
writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getLocalRootCA()) 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())
}
}
}
for (rhOS in ubiOS) { for (rhOS in ubiOS) {
for (image in ubiImages) { for (image in ubiImages) {
def updateCmd stage ("Build ubi${rhOS}:${image}") {
if (image == "ubi-minimal") { steps {
updateCmd = "microdnf" script {
} else { def updateCmd
updateCmd = "dnf" if (image == "ubi-minimal") {
} updateCmd = "microdnf"
def dockerFile = """FROM registry.access.redhat.com/ubi${rhOS}/${image}:latest } else {
updateCmd = "dnf"
}
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,13 +58,23 @@ 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, dockerFile: dockerFile,
imageDest: "${repository}/library/rhubi/${image}:${rhOS}", repositoryAccess: [
dockerFile: dockerFile, [
repoCreds: repositoryCreds, repository: repository,
) credentials: repositoryCreds
],
],
destination: [
"${repository}/library/rhubi/${image}:${rhOS}",
]
)
}
}
}
}
} }
} }
} }