#!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 " 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" ) } } } } } }