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 repositoryCreds = "harbor-repository-creds"
def ubiOS = ["8"]
def ubiImages = ["ubi-minimal", "ubi"]
def workspace
def dockerFile
def ubiOS
def ubiImages
def label = "kubernetes-${UUID.randomUUID().toString()}"
def templateName = "pipeline-worker"
podTemplate (
label: label,
name: templateName,
yaml: functions.podYaml(
repo: repository,
templateName: templateName,
kaniko: true
)
){
node (label) {
def workspace = pwd()
pipeline {
agent {
kubernetes {
yaml functions.podYaml(
repo: repository,
templateName: templateName,
kaniko: true
)
}
}
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 (image in ubiImages) {
def updateCmd
if (image == "ubi-minimal") {
updateCmd = "microdnf"
} else {
updateCmd = "dnf"
}
def dockerFile = """FROM registry.access.redhat.com/ubi${rhOS}/${image}:latest
stage ("Build ubi${rhOS}:${image}") {
steps {
script {
def updateCmd
if (image == "ubi-minimal") {
updateCmd = "microdnf"
} 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
@ -40,13 +58,23 @@ RUN update-ca-trust extract && \\
${updateCmd} update -y && \\
${updateCmd} clean all
"""
functions.buildContainer(
repository: repository,
imageDest: "${repository}/library/rhubi/${image}:${rhOS}",
dockerFile: dockerFile,
repoCreds: repositoryCreds,
)
container ("kaniko") {
declarativeFunctions.buildContainerMultipleDestinations(
dockerFile: dockerFile,
repositoryAccess: [
[
repository: repository,
credentials: repositoryCreds
],
],
destination: [
"${repository}/library/rhubi/${image}:${rhOS}",
]
)
}
}
}
}
}
}
}