Refactor Jenkinsfile (same structure as in PaperDockerBuilder)
This commit is contained in:
parent
d5e743c6e3
commit
bb5e7d7557
43
Jenkinsfile
vendored
43
Jenkinsfile
vendored
@ -4,50 +4,55 @@ Required plugins in Jenkins:
|
||||
- Docker Pipeline
|
||||
*/
|
||||
|
||||
def geyser_version
|
||||
def geyser_build
|
||||
def runnable_jar
|
||||
def app_version
|
||||
def app_build
|
||||
def url_download
|
||||
def app_filename
|
||||
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"
|
||||
URL_BASE = 'https://download.geysermc.org/v2/projects/geyser/versions'
|
||||
URL_BUILD_INFOS = "${URL_BASE}/latest/builds/latest"
|
||||
|
||||
DOCKER_TAG_BASE = 'cr.pandacube.fr/geyser'
|
||||
DOCKER_CR_PANDACUBE_CREDENTIALS = 'cr-pandacube-credentials'
|
||||
DOCKER_REGISTRY_URL = 'https://cr.pandacube.fr'
|
||||
DOCKER_REGISTRY_CREDENTIALS = 'cr-pandacube-credentials'
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Get build data') {
|
||||
steps {
|
||||
sh 'curl -L -s $URL_BUILD -o build_infos.json'
|
||||
sh "curl -L -s '$URL_BUILD_INFOS' -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}"
|
||||
|
||||
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}"
|
||||
docker_tag_latest = "${DOCKER_TAG_BASE}:latest"
|
||||
}
|
||||
echo "Geyser version ${geyser_version} build #${geyser_build}"
|
||||
echo "Geyser version ${app_version} build #${app_build}"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Download jar') {
|
||||
steps {
|
||||
echo "From $URL_DOWNLOAD"
|
||||
echo "To $runnable_jar"
|
||||
sh "curl -L -o '$runnable_jar' '$URL_DOWNLOAD'"
|
||||
sh "curl -L -o '$app_filename' '$URL_DOWNLOAD'"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker image') {
|
||||
steps {
|
||||
script {
|
||||
docker.build(docker_tag, "--build-arg RUNNABLE_JAR=$runnable_jar .")
|
||||
docker.build(docker_tag, "--build-arg RUNNABLE_JAR=$app_filename .")
|
||||
}
|
||||
sh "docker tag ${docker_tag} ${docker_tag_latest}"
|
||||
}
|
||||
@ -56,7 +61,7 @@ pipeline {
|
||||
stage('Push Docker image') {
|
||||
steps {
|
||||
script {
|
||||
docker.withRegistry('https://cr.pandacube.fr', DOCKER_CR_PANDACUBE_CREDENTIALS) {
|
||||
docker.withRegistry(DOCKER_REGISTRY_URL, DOCKER_REGISTRY_CREDENTIALS) {
|
||||
docker.image(docker_tag).push()
|
||||
docker.image(docker_tag_latest).push()
|
||||
}
|
||||
@ -65,8 +70,8 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
post {
|
||||
cleanup {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user