#!groovy def gitlabRepo = "registry.c.test-chamber-13.lan/gitlab/gitlab-org/build/cng" def gitlabImages = [ "gitlab-toolbox-ee", "gitlab-webservice-ee", ] def gitlabVersion = "v17.10.0" def gitlabPublicKey def repository = "registry.c.test-chamber-13.lan" def repositoryCreds = "harbor-repository-creds" def shortCommit 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() gitlabPublicKey = """-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAreEfP/ncA1A5cuxBz7rS 0Z9DDxdSymLwt2OUSM5WJa+dVB3zSpQjinifdNZq+iHVt8toZBZZ02H3unbn8td0 rIifoj4oVpLhvnOAVjUn5tZeUX17tWMA+yyBpf6w6IFxeYBXFd14WOKEarS05U9B 59DjBxNqSm+GzhljHO7vvTKy2xXQQ7Fa702DZ7jwr4DJnL87bDXfarnYksuawqtK wQbFHAOvxFj8ghBh1Gshap1abExD4l7QWxFMTCVOkLJmXiqfOi5KuMiaMsSUsCBN QDE3A5aKvpwLGozsvpGRMy5Tt4SgHC7ZbgerBNe75olOoPDxZf7bBt0+O5A/UjK/ HwIDAQAB -----END PUBLIC KEY----- """ writeFile(file: workspace + "/.license_encryption_key.pub", text: gitlabPublicKey) } } } stage ('Build Images') { steps { script { for (gitlabImage in gitlabImages) { stage("Build ${gitlabImage}") { dockerFile = """FROM ${gitlabRepo}/${gitlabImage}:${gitlabVersion} COPY .license_encryption_key.pub /srv/gitlab/.license_encryption_key.pub """ container ('kaniko') { script { declarativeFunctions.buildContainerMultipleDestinations( dockerFile: dockerFile, repositoryAccess: [ [ repository: repository, credentials: repositoryCreds, ], ], destination: [ "${repository}/library/gitlab/${gitlabImage}:${gitlabVersion}", ] ) } } } } } } } } }