diff --git a/build-minecraft.jenkins b/build-minecraft.jenkins index 488c80e..658748f 100644 --- a/build-minecraft.jenkins +++ b/build-minecraft.jenkins @@ -44,8 +44,44 @@ spec: // Set working directory def workspace = pwd() - // Set dockerfile - def dockerFile = """ + stage ("Prepare Kaniko") { + container ("kaniko") { + withCredentials([usernameColonPassword( + credentialsId: repositoryCreds, + variable: "dCreds", + )]) { + def dockerJSON = """{ + "auths": { + "${repository}": { + "auth": "${dcreds.bytes.encodeBase64().toString()}" + } + } + }""" + sh """ + set +x + echo '${dockerJSON}' > /kaniko/.docker/config.json + """ + } + } + } + + stage ("Get Paper-MC Version") { + container ("alpine") { + sh "apk add --no-cache curl jq" + paperDownload = sh ( + script: """ + paperBuild=\$(curl --silent --location --fail https://papermc.io/api/v2/projects/paper/versions/${paperVersion} | jq '.builds | max') + paperFile=\$(curl --silent --location --fail https://papermc.io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild} | jq '.downloads.application.name') + echo https://papermc.io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild}/downloads/\${paperFile} + """, + returnStdout: true + ).trim() + } + } + + stage ("Create Dockerfile") { + // Set dockerfile + def dockerFile = """ FROM ${buildImage}:${buildImageTag} as builder @@ -68,46 +104,9 @@ WORKDIR /minecraft/data CMD ["java", "-Xms${memoryMin}", "-Xmx${memoryMax}", "-jar ../paper-mc.jar"] """ - - stage ("Prepare Kaniko") { - container ("kaniko") { - withCredentials([usernameColonPassword( - credentialsId: repositoryCreds, - variable: "dCreds", - )]) { - def dockerJSON = """{ - "auths": { - "${repository}": { - "auth": "${dcreds.bytes.encodeBase64().toString()}" - } - } - }""" - sh """ - set +x - echo '${dockerJSON}' > /kaniko/.docker/config.json - """ - } - } - } - - stage ("Create Dockerfile") { writeFile(file: workspace + '/Dockerfile', text: dockerFile) } - stage ("Get Paper-MC Version") { - container ("alpine") { - sh "apk add --no-cache curl jq" - paperDownload = sh ( - script: """ - paperBuild=\$(curl --silent --location --fail https://papermc.io/api/v2/projects/paper/versions/${paperVersion} | jq '.builds | max') - paperFile=\$(curl --silent --location --fail https://papermc.io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild} | jq '.downloads.application.name') - echo https://papermc.io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild}/downloads/\${paperFile} - """, - returnStdout: true - ).trim() - } - } - stage ("Build & Push") { container ("kaniko") { sh """