updates to declarative pipeline
This commit is contained in:
parent
e6523afd24
commit
b17f820236
@ -1,11 +1,37 @@
|
||||
#!groovy
|
||||
|
||||
def repository = "registry.c.test-chamber-13.lan"
|
||||
def repositoryCreds = "harbor-repository-creds"
|
||||
|
||||
def paperVersion = "1.18.1"
|
||||
def memoryMin = "1g"
|
||||
def memoryMax = "48g"
|
||||
def workspace
|
||||
def dockerFile
|
||||
def paperVersion
|
||||
def memoryMin
|
||||
def memoryMax
|
||||
|
||||
def dockerFile = """FROM registry.c.test-chamber-13.lan/library/alpine:latest as builder
|
||||
def label = "kubernetes-${UUID.randomUUID().toString()}"
|
||||
def templateName = "pipeline-worker"
|
||||
pipeline {
|
||||
agent {
|
||||
kubernetes {
|
||||
yaml functions.podYaml(
|
||||
repo: repository,
|
||||
templateName: templateName,
|
||||
kaniko: true,
|
||||
alpine: true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
stages {
|
||||
stage ('Initalize Jenkins') {
|
||||
steps {
|
||||
script {
|
||||
workspace = pwd()
|
||||
paperVersion = "1.18.2"
|
||||
memoryMin = "1g"
|
||||
memoryMax = "48g"
|
||||
dockerFile = """FROM registry.c.test-chamber-13.lan/library/alpine:latest as builder
|
||||
|
||||
ARG paperDownload
|
||||
|
||||
@ -31,44 +57,54 @@ WORKDIR /minecraft/data
|
||||
ENTRYPOINT ["/usr/bin/java", "-Xms${memoryMin}", "-Xmx${memoryMax}", "-jar"]
|
||||
CMD ["../paper-mc.jar"]
|
||||
"""
|
||||
|
||||
def label = "kubernetes-${UUID.randomUUID().toString()}"
|
||||
def templateName = "pipeline-worker"
|
||||
podTemplate(
|
||||
label: label,
|
||||
name: templateName,
|
||||
yaml: functions.podYaml(
|
||||
repo: repository,
|
||||
templateName: templateName,
|
||||
kaniko: true,
|
||||
alpine: true
|
||||
)
|
||||
) {
|
||||
node (label) {
|
||||
def workspace = pwd()
|
||||
|
||||
stage ("Get Paper-MC Version") {
|
||||
container ("alpine") {
|
||||
sh "apk add --no-cache curl jq"
|
||||
paperDownload = sh (
|
||||
script: """
|
||||
paperBuild=\$(curl --silent --location --fail https://nexus.c.test-chamber-13.lan/repository/paper-io/api/v2/projects/paper/versions/${paperVersion} | jq '.builds | max')
|
||||
paperFile=\$(curl --silent --location --fail https://nexus.c.test-chamber-13.lan/repository/paper-io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild} | jq '.downloads.application.name')
|
||||
echo https://nexus.c.test-chamber-13.lan/repository/paper-io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild}/downloads/\${paperFile}
|
||||
""",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
functions.buildContainer(
|
||||
repository: repository,
|
||||
imageDest: "${repository}/library/minecraft:latest",
|
||||
dockerFile: dockerFile,
|
||||
repoCreds: repositoryCreds,
|
||||
[
|
||||
"paperDownload=${paperDownload}"
|
||||
]
|
||||
)
|
||||
stage ("Get Paper-MC Version") {
|
||||
steps {
|
||||
container ("alpine") {
|
||||
script {
|
||||
sh """
|
||||
if [ ! -f "/usr/bin/curl" ] || [ ! -x "/usr/bin/curl" ]; then
|
||||
apk add --no-cache curl
|
||||
fi
|
||||
if [ ! -f "/usr/bin/jq" ] || [ ! -x "/usr/bin/jq" ]; then
|
||||
apk add --no-cache jq
|
||||
fi
|
||||
"""
|
||||
paperDownload = sh (
|
||||
script: """
|
||||
paperBuild=\$(curl --silent --location --fail https://nexus.c.test-chamber-13.lan/repository/paper-io/api/v2/projects/paper/versions/${paperVersion} | jq '.builds | max')
|
||||
paperFile=\$(curl --silent --location --fail https://nexus.c.test-chamber-13.lan/repository/paper-io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild} | jq '.downloads.application.name')
|
||||
echo https://nexus.c.test-chamber-13.lan/repository/paper-io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild}/downloads/\${paperFile}
|
||||
""",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage ('Build & Push') {
|
||||
steps {
|
||||
container ('kaniko') {
|
||||
script {
|
||||
declarativeFunctions.buildContainerMultipleDestinations(
|
||||
dockerFile: dockerFile,
|
||||
repositoryAccess: [
|
||||
[
|
||||
repository: repository,
|
||||
credentials: repositoryCreds
|
||||
],
|
||||
],
|
||||
destination: [
|
||||
"${repository}/library/minecraft:latest",
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user