GeyserDockerBuilder/Jenkinsfile

78 lines
2.1 KiB
Plaintext
Raw Normal View History

2024-01-16 16:51:00 +01:00
/*
Required plugins in Jenkins:
- Pipeline Utility Steps
- Docker Pipeline
*/
def app_version
def app_build
def url_download
def app_filename
2024-01-16 16:51:00 +01:00
def docker_tag
def docker_tag_latest
pipeline {
agent any
2024-01-16 16:51:00 +01:00
environment {
URL_BASE = 'https://download.geysermc.org/v2/projects/geyser/versions'
URL_BUILD_INFOS = "${URL_BASE}/latest/builds/latest"
2024-01-16 16:51:00 +01:00
DOCKER_TAG_BASE = 'cr.pandacube.fr/geyser'
DOCKER_REGISTRY_URL = 'https://cr.pandacube.fr'
DOCKER_REGISTRY_CREDENTIALS = 'cr-pandacube-credentials'
2024-01-16 16:51:00 +01:00
}
stages {
stage('Get build data') {
steps {
sh "curl -L -s '$URL_BUILD_INFOS' -o build_infos.json"
2024-01-16 16:51:00 +01:00
script {
def build_infos = readJSON file: 'build_infos.json'
app_version = build_infos.version
app_build = build_infos.build
url_download = "${URL_BASE}/${app_version}/builds/${app_build}/downloads/standalone"
app_filename = "Geyser-${app_version}-${app_build}.jar"
docker_tag = "${DOCKER_TAG_BASE}:${app_version}-${app_build}"
2024-01-16 16:51:00 +01:00
docker_tag_latest = "${DOCKER_TAG_BASE}:latest"
}
echo "Geyser version ${app_version} build #${app_build}"
2024-01-16 16:51:00 +01:00
}
}
stage('Download jar') {
steps {
sh "curl -L -o '$app_filename' '$URL_DOWNLOAD'"
2024-01-16 16:51:00 +01:00
}
}
stage('Build Docker image') {
steps {
script {
docker.build(docker_tag, "--build-arg RUNNABLE_JAR=$app_filename .")
2024-01-16 16:51:00 +01:00
}
sh "docker tag ${docker_tag} ${docker_tag_latest}"
}
}
stage('Push Docker image') {
steps {
script {
docker.withRegistry(DOCKER_REGISTRY_URL, DOCKER_REGISTRY_CREDENTIALS) {
2024-01-16 16:51:00 +01:00
docker.image(docker_tag).push()
docker.image(docker_tag_latest).push()
}
}
}
}
}
post {
cleanup {
2024-01-16 16:51:00 +01:00
cleanWs()
}
}
}