From 9e3bef91f0c43be4a0a1b860f72347610020e165 Mon Sep 17 00:00:00 2001 From: The_Spider Date: Fri, 1 Apr 2022 17:21:47 -0500 Subject: [PATCH] attempts to switch to declarative format --- build-ubi.jenkins | 86 +++++++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/build-ubi.jenkins b/build-ubi.jenkins index 8d12dd4..b416581 100644 --- a/build-ubi.jenkins +++ b/build-ubi.jenkins @@ -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 " +LABEL org.opencontainers.image.authors="The_Spider " +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}", + ] + ) + } + } + } + } } } }