Adds build-gitlab.jenkins

This commit is contained in:
Hyatt 2025-03-03 08:51:07 -06:00
parent 1aa78c2078
commit 19702150ca
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

80
build-gitlab.jenkins Normal file
View File

@ -0,0 +1,80 @@
#!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.9.1"
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}",
]
)
}
}
}
}
}
}
}
}
}