Clean's up RH-UBI Creation.

This commit is contained in:
Hyatt 2021-06-07 15:38:31 -05:00
parent e2080db33d
commit 4026b40c75

View File

@ -8,9 +8,9 @@ def ubiOS = ["8"]
def ubiImages = ["ubi-minimal", "ubi"] def ubiImages = ["ubi-minimal", "ubi"]
podTemplate( podTemplate(
label: label, label: label,
name: "pipeline-worker", name: "pipeline-worker",
yaml: """--- yaml: """---
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
@ -24,60 +24,61 @@ spec:
command: command:
- /busybox/cat - /busybox/cat
""") { """) {
node (label) { node (label) {
def workspace = pwd() def workspace = pwd()
stage ("Prepare Kaniko") { stage ("Prepare Kaniko") {
container ("kaniko") { container ("kaniko") {
withCredentials([usernameColonPassword( withCredentials([usernameColonPassword(
credentialsId: repositoryCreds, credentialsId: repositoryCreds,
variable: "dCreds", variable: "dCreds",
)]) { )]) {
def dockerJSON = """{ def dockerJSON = """{
"auths": { "auths": {
"${repository}": { "${repository}": {
"auth": "${dcreds.bytes.encodeBase64().toString()}" "auth": "${dcreds.bytes.encodeBase64().toString()}"
} }
} }
}""" }"""
sh """
set +x
echo '${dockerJSON}' > /kaniko/.docker/config.json
"""
}
}
}
for (rhOS in ubiOS) { sh """
for (image in ubiImages) { set +x
container("kaniko") { echo '${dockerJSON}' > /kaniko/.docker/config.json
stage ("Build " + image + ":" + rhOS) { """
def DF = """FROM registry.access.redhat.com//ubi${rhOS}/${image}:latest }
}
}
for (rhOS in ubiOS) {
for (image in ubiImages) {
container("kaniko") {
stage ("Build " + image + ":" + rhOS) {
def DF = """FROM registry.access.redhat.com//ubi${rhOS}/${image}:latest
RUN printf '%s\\n' "-----BEGIN CERTIFICATE-----" \\ RUN printf '%s\\n' "-----BEGIN CERTIFICATE-----" \\
"MIICLTCCAbOgAwIBAgIDAYagMAoGCCqGSM49BAMEME0xCzAJBgNVBAYTAlVTMScw" \\ "MIICLTCCAbOgAwIBAgIDAYagMAoGCCqGSM49BAMEME0xCzAJBg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" \\ "BBgwFoAUrGqUJhyRp93wXF645VNtYatRk/AwDwYDVR0TAQH/BAUwAwEB/zAOBgNV" \\
"HQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwQDaAAwZQIxAJdgskimDJkf/MGVRrKotmNC" \\ "HQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwQDaAAwZQIxAJdgskimDJkf/MGVRrKotmNC" \\
"xdH/UVQfQppjIR9FAiGeFDr47thclYrzIL6yCkV7nwIwYjf3MbOm/yWblzqe3Uyw" \\ "xdH/UVQfQppjIR9FAiGeFDr47thclYrzIL6yCkV7nwIwYjf3MbOm/yWblzqe3Uyw" \\
"UOemMEg3PjcKNsN65W2WVon5HIZx2XVfGRPjf5ZTVWzZ" \\ "UOemMEg3PjcKNsN65W2WVon5HIZx2XVfGRPjf5ZTVWzZ" \\
"-----END CERTIFICATE-----" > /etc/pki/ca-trust/source/anchors/test-chamber-13.lan.root.crt && \\ "-----END CERTIFICATE-----" > /etc/pki/ca-trust/source/anchors/test-chamber-13.lan.root.crt && \\
update-ca-trust extract && \\ update-ca-trust extract && \\
microdnf update -y && \\ microdnf update -y && \\
microdnf clean all microdnf clean all
""" """
writeFile(file: workspace + '/Dockerfile', text: DF) writeFile(file: workspace + '/Dockerfile', text: DF)
sh "/kaniko/executor --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${repository}/library/${image}:${rhOS}\"" sh "/kaniko/executor --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${repository}/library/${image}:${rhOS}\""
} }
} }
} }
} }
} }
} }