diff --git a/build-gitea.jenkins b/build-gitea.jenkins index bbe5283..fbef360 100644 --- a/build-gitea.jenkins +++ b/build-gitea.jenkins @@ -3,7 +3,30 @@ def repository = "registry.c.test-chamber-13.lan" def repositoryCreds = "harbor-repository-creds" -def dockerFile = """FROM ${repository}/dockerhub/gitea/gitea:latest-rootless +def workspace +def dockerFile + +def label = "kubernetes-${UUID.randomUUID().toString()}" +def templateName = "pipeline-worker" +pipeline { + agent { + kubernetes { + yaml functions.podYaml( + repo: repository, + templateName: templateName, + kaniko: true, + alpine: true + ) + } + } + + stages { + stage ('Initalize Jenkins') { + steps { + script { + workspace = pwd() + writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getLocalRootCA()) + dockerFile = """FROM ${repository}/dockerhub/gitea/gitea:latest-rootless USER root @@ -15,38 +38,47 @@ RUN apk add --no-cache --virtual=.packagecache ca-certificates && \\ USER git """ + } + } -def label = "kubernetes-${UUID.randomUUID().toString()}" -def templateName = "pipeline-worker" -podTemplate( - label: label, - name: templateName, - yaml: functions.podYaml( - repo: repository, - templateName: templateName, - kaniko: true, - alpine: true - ) -) { - node (label) { - def workspace = pwd() - - stage ('Write cert to local file') { - writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getLocalRootCA()) + stage ('Build & Push') { + steps { + container ('kaniko') { + script { + declarativeFunctions.buildContainerMultipleDestinations( + dockerFile: dockerFile, + repositoryAccess: [ + [ + repository: repository, + credentials: repositoryCreds + ], + ], + destination: [ + "${repository}/library/gitea:latest-rootless", + ], + [ + "LANG=${GlibcLanguage}", + "TZ=${TimeZone}" + ] + ) + } + } + } } - functions.buildContainer( - repository: repository, - imageDest: "${repository}/library/gitea:latest-rootless", - dockerFile: dockerFile, - repoCreds: repositoryCreds - ) - - functions.deletePod( - kubeAuth: "k8s-development-access", - kubeURL: "https://kubernetes.test-chamber-13.lan:6443", - namespace: "development", - selector: "app=gitea,app.kubernetes.io/name=gitea" - ) + stage ('Delete Running Container') { + steps { + container ('alpine') { + script { + declarativeFunctions.deletePod( + kubeAuth: "k8s-development-access", + kubeURL: "https://kubernetes.test-chamber-13.lan:6443", + namespace: "development", + selector: "app=gitea,app.kubernetes.io/name=gitea" + ) + } + } + } + } } } \ No newline at end of file