This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
build-containers/build-projectzomboid.jenkins
2022-07-06 21:53:23 -05:00

80 lines
2.2 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()
dockerFile = """
FROM ${repository}/dockerhub/cm2network/steamcmd:latest
LABEL org.opencontainers.image.authors="The_Spider <spider@smoothnet.org>"
LABEL org.opencontainers.image.title="projectzomboid"
EXPOSE 16261/udp
EXPOSE 27015/udp
RUN /home/steam/steamcmd/steamcmd.sh +quit && \\
/home/steam/steamcmd/steamcmd.sh +force_install_dir /home/steam/ProjectZomboid +login anonymous +app_update 380870 validate +quit
WORKDIR /home/steam/ProjectZomboid
ENTRYPOINT ["/bin/bash", "-c", "/home/steam/ProjectZomboid/start-server.sh"]
"""
}
}
}
stage ('Build & Push') {
steps {
container ('kaniko') {
script {
declarativeFunctions.buildContainer(
repository: repository,
imageDest: "${repository}/library/project-zomboid:latest",
dockerFile: dockerFile,
repoCreds: repositoryCreds,
)
}
}
}
}
stage ('Delete Running Container') {
steps {
container ('alpine') {
script {
declarativeFunctions.functions.deletePod(
kubeAuth: "k8s-game-servers-access",
kubeURL: "https://k8s.test-chamber-13.lan:8043",
namespace: "game-servers",
selector: "app=project-zomboid"
)
}
}
}
}
}
}