82 lines
2.5 KiB
Groovy
82 lines
2.5 KiB
Groovy
#!groovy
|
|
|
|
def repository = "registry.c.test-chamber-13.lan"
|
|
def repositoryCreds = "harbor-repository-creds"
|
|
|
|
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.getCurrentRootCA())
|
|
writeFile(file: workspace + "/test-chamber-13.lan.ret.root.crt", text: functions.getRetiredRootCA())
|
|
dockerFile = """FROM ${repository}/dockerhub/gitea/gitea:latest-rootless
|
|
|
|
USER root
|
|
|
|
COPY test-chamber-13.lan.root.crt test-chamber-13.lan.ret.root.crt /usr/local/share/ca-certificates/
|
|
|
|
RUN apk add --no-cache --virtual=.packagecache ca-certificates && \\
|
|
update-ca-certificates --fresh && \\
|
|
apk del .packagecache
|
|
|
|
USER git
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
|
|
stage ('Build & Push') {
|
|
steps {
|
|
container ('kaniko') {
|
|
script {
|
|
declarativeFunctions.buildContainerMultipleDestinations(
|
|
dockerFile: dockerFile,
|
|
repositoryAccess: [
|
|
[
|
|
repository: repository,
|
|
credentials: repositoryCreds
|
|
],
|
|
],
|
|
destination: [
|
|
"${repository}/library/gitea:latest-rootless",
|
|
]
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage ('Delete Running Container') {
|
|
steps {
|
|
container ('alpine') {
|
|
script {
|
|
declarativeFunctions.deletePod(
|
|
kubeAuth: "k8s-development-access",
|
|
kubeURL: "https://k8s.test-chamber-13.lan:8043",
|
|
namespace: "development",
|
|
selector: "app=gitea,app.kubernetes.io/name=gitea"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |