use new build process

This commit is contained in:
Hyatt 2022-01-27 12:13:44 -06:00
parent 7254291e24
commit 89e016e891

View File

@ -1,75 +1,49 @@
def label = "jenkins-${UUID.randomUUID().toString()}" #!groovy
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 dockerKey = "docker-image-signing-key"
def dockerKeyPass = "docker-image-signing-pass"
podTemplate( def dockerFile = """FROM ${repository}/google/kaniko-project/executor:debug
COPY ./kaniko-chain.crt /kaniko/ssl/certs/ca-certificates.crt
"""
def label = "kubernetes-${UUID.randomUUID().toString()}"
def templateName = "pipeline-worker"
podTemplate (
label: label, label: label,
name: "pipeline-worker", name: templateName,
yaml: """--- yaml: functions.podYaml(
apiVersion: v1 repo: repository,
kind: Pod templateName: templateName,
metadata: [
name: pipeline-worker [
spec: name: "kaniko",
containers: image: "${repository}/google/kaniko-project/executor:debug",
- name: kaniko command: "/busybox/sh"
imagePullPolicy: Always ]
image: ${repository}/google/kaniko-project/executor:debug ]
tty: true )
command: ){
- /busybox/sh
""",
) {
node (label) { node (label) {
def workspace = pwd() def workspace = pwd()
stage ("Prepare Kaniko") { writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getLocalRootCA())
stage ("Add Cert to Kaniko") {
container ("kaniko") { container ("kaniko") {
withCredentials([usernameColonPassword( sh """
credentialsId: repositoryCreds, printf '%s\\n' "${functions.getLocalRootCA)" >> /kaniko/ssl/certs/ca-certificates.crt
variable: "dCreds", cp "/kaniko/ssl/certs/ca-certificates.crt" "${workspace}/kaniko-chain.crt"
)]) { """
def dockerJSON = """{
"auths": {
"${repository}": {
"auth": "${dcreds.bytes.encodeBase64().toString()}"
}
}
}"""
sh """
set +x
echo '${dockerJSON}' > /kaniko/.docker/config.json
printf '%s\\n' "-----BEGIN CERTIFICATE-----" \\
"MIICLTCCAbOgAwIBAgIDAYagMAoGCCqGSM49BAMEME0xCzAJBgNVBAYTAlVTMScw" \\
"JQYDVQQKDB5UZXN0IENoYW1iZXIgMTMgVHJ1c3QgU2VydmljZXMxFTATBgNVBAMM" \\
"DFRDMTMgUm9vdCBSMTAgFw0xOTAxMDEwMDAwMDBaGA8yMDUwMDEwMTAwMDAwMFow" \\
"TTELMAkGA1UEBhMCVVMxJzAlBgNVBAoMHlRlc3QgQ2hhbWJlciAxMyBUcnVzdCBT" \\
"ZXJ2aWNlczEVMBMGA1UEAwwMVEMxMyBSb290IFIxMHYwEAYHKoZIzj0CAQYFK4EE" \\
"ACIDYgAE8+/J1ECc0VHxTtGXFLnHJ3NGZ2SW38pp9wI58L5EQbHRLiezYuvkUbI/" \\
"XGJjLnFdpgjo7W1FFlyhx5ITlCstUX5Sn9bLZiA0+mE0n6b8VwhXwkHlnIeRo7od" \\
"Zu/OfSFjo2MwYTAdBgNVHQ4EFgQUrGqUJhyRp93wXF645VNtYatRk/AwHwYDVR0j" \\
"BBgwFoAUrGqUJhyRp93wXF645VNtYatRk/AwDwYDVR0TAQH/BAUwAwEB/zAOBgNV" \\
"HQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwQDaAAwZQIxAJdgskimDJkf/MGVRrKotmNC" \\
"xdH/UVQfQppjIR9FAiGeFDr47thclYrzIL6yCkV7nwIwYjf3MbOm/yWblzqe3Uyw" \\
"UOemMEg3PjcKNsN65W2WVon5HIZx2XVfGRPjf5ZTVWzZ" \\
"-----END CERTIFICATE-----" >> /kaniko/ssl/certs/ca-certificates.crt
"""
}
} }
} }
stage("Build Kaniko with CA") { functions.buildContainer(
container("kaniko") { repository: repository,
def DF = """FROM ${repository}/google/kaniko-project/executor:debug imageDest: "${repository}/library/kaniko:latest",
COPY ./kaniko-chain.crt /kaniko/ssl/certs/ca-certificates.crt dockerFile: dockerFile,
""" repoCreds: repositoryCreds,
sh "cp /kaniko/ssl/certs/ca-certificates.crt \"${workspace}/kaniko-chain.crt\"" )
writeFile(file: workspace + "/Dockerfile", text: DF)
sh "/kaniko/executor --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${repository}/library/kaniko:latest\""
}
}
} }
} }