diff --git a/build-php.jenkins b/build-php.jenkins index f3f47df..a4d9606 100644 --- a/build-php.jenkins +++ b/build-php.jenkins @@ -3,7 +3,29 @@ def repository = "registry.c.test-chamber-13.lan" def repositoryCreds = "harbor-repository-creds" -def dockerFile = """FROM ${repository}/dockerhub/library/php:apache +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 + ) + } + } + + stages { + stage ('Initalize Jenkins') { + steps { + script { + workspace = pwd() + writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getLocalRootCA()) + dockerFile = """FROM ${repository}/dockerhub/library/php:apache LABEL org.opencontainers.image.authors="The_Spider " @@ -16,28 +38,29 @@ RUN apt-get update && \\ rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/* && \\ docker-php-ext-install mysqli """ + } + } + } -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() - - writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getLocalRootCA()) - - functions.buildContainer( - repository: "registry.hub.docker.com", - imageDest: "registry.hub.docker.com/thespider/php-mysqli:latest", - dockerFile: dockerFile, - repoCreds: "dockerhub-repository-creds", - ) + stage ('Build & Push') { + steps { + container ('kaniko') { + script { + declarativeFunctions.buildContainerMultipleDestinations( + dockerFile: dockerFile, + repositoryAccess: [ + [ + repository: "registry.hub.docker.com", + credentials: "dockerhub-repository-creds" + ], + ], + destination: [ + "registry.hub.docker.com/thespider/php-mysqli:latest", + ] + ) + } + } + } + } } } \ No newline at end of file