GeyserDockerBuilder/Jenkinsfile
2024-01-16 17:17:27 +01:00

73 lines
2.1 KiB
Groovy

/*
Required plugins in Jenkins:
- Pipeline Utility Steps
- Docker Pipeline
*/
def geyser_version
def geyser_build
def runnable_jar
def docker_tag
def docker_tag_latest
pipeline {
agent any
environment {
URL_BUILD = 'https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest'
URL_DOWNLOAD = "${URL_BUILD}/downloads/standalone"
DOCKER_TAG_BASE = 'cr.pandacube.fr/geyser'
DOCKER_CR_PANDACUBE_CREDENTIALS = 'cr-pandacube-credentials'
}
stages {
stage('Get build data') {
steps {
sh 'curl -L -s $URL_BUILD -o build_infos.json'
script {
def build_infos = readJSON file: 'build_infos.json'
geyser_version = build_infos.version
geyser_build = build_infos.build
runnable_jar = "Geyser-${geyser_version}-${geyser_build}.jar"
docker_tag = "${DOCKER_TAG_BASE}:${GEYSER_VERSION}-${GEYSER_BUILD}"
docker_tag_latest = "${DOCKER_TAG_BASE}:latest"
}
echo "Geyser version ${geyser_version} build #${geyser_build}"
}
}
stage('Download jar') {
steps {
echo "From $URL_DOWNLOAD"
echo "To $runnable_jar"
sh "curl -L -o '$runnable_jar' '$URL_DOWNLOAD'"
}
}
stage('Build Docker image') {
steps {
script {
docker.build(docker_tag, "--build-arg RUNNABLE_JAR=$runnable_jar .")
}
sh "docker tag ${docker_tag} ${docker_tag_latest}"
}
}
stage('Push Docker image') {
steps {
script {
docker.withRegistry('cr.pandacube.fr', DOCKER_CR_PANDACUBE_CREDENTIALS) {
docker.image(docker_tag).push()
docker.image(docker_tag_latest).push()
}
}
}
}
}
post {
always {
cleanWs()
}
}
}