Jenkins pipeline
This commit is contained in:
parent
5e87c92213
commit
cd94a6112c
73
Jenkinsfile
vendored
Normal file
73
Jenkinsfile
vendored
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
Readme.md
25
Readme.md
@ -1,10 +1,29 @@
|
|||||||
Docker Compose Example
|
# GeyserDockerBuilder
|
||||||
|
|
||||||
|
Jenkins pipeline to build a Docker image of Geyser Standalone.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
build.sh # the old pipeline script, not used anymore
|
||||||
|
Dockerfile # used to build the image
|
||||||
|
Jenkinsfile # the new pipeline script
|
||||||
|
Readme.md # you are reading this file
|
||||||
|
run.sh # entrypoint of the docker image
|
||||||
|
```
|
||||||
|
|
||||||
|
## Pipeline process
|
||||||
|
|
||||||
|
- Fetches the information about the latest build of Geyser (version, build number), from the [GeyserMC API](https://download.geysermc.org/v2/projects)
|
||||||
|
- Downloads the Geyser Standalone jar file.
|
||||||
|
- Builds the docker image with the downloaded jar and the entrypoint script.
|
||||||
|
- Pushes the image to the container registry with the tags `latest` and `$geyser_version-$geyser_build` (e.g. `2.2.0-408`)
|
||||||
|
|
||||||
|
## Docker Compose Example
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
(server-name):
|
geyser:
|
||||||
image: "cr.pandacube.fr/geyser:(version)"
|
image: "cr.pandacube.fr/geyser:latest"
|
||||||
stdin_open: true # docker run -i
|
stdin_open: true # docker run -i
|
||||||
tty: true # docker run -t
|
tty: true # docker run -t
|
||||||
user: "1000:1000" # uid and gid of owner of working dir
|
user: "1000:1000" # uid and gid of owner of working dir
|
||||||
|
Loading…
Reference in New Issue
Block a user