Yatopia/Jenkinsfile
tofikarz 920fdd1703
Changes to Jenkinsfile (#451)
* Maybe this works?

Changed/Added:

+ Archive artifacts in its own build stage?
+ Gradlew clean
+ Delete the work dir in Paper
+ Always clean Ws after build?

* chmod dir???

i don't see this necessary but maybe?

* do not clean when build publish?

* Remove jenkins workspace?

Maybe this fixes somethings?

* turned off git gc

Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
2021-04-12 11:34:11 -04:00

90 lines
3.2 KiB
Groovy

pipeline {
agent { label 'slave' }
options { timestamps() }
stages {
stage('Cleanup') {
steps {
scmSkip(deleteBuild: true, skipPattern:'.*\\[CI-SKIP\\].*')
sh 'git config --global gc.auto 0'
sh 'rm -rf ./target'
sh 'rm -rf ./Paper/Paper-API ./Paper/Paper-Server ./Paper/work'
sh 'rm -rf ./Yatopia-API ./Yatopia-Server'
sh 'find /home/jenkins/workspace/YatopiaMC_Yatopia_ver_1.16.5 -type d -exec chmod 755 {} \;'
sh 'chmod +x ./gradlew
sh './gradlew clean'
}
}
stage('Init project & submodules') {
steps {
withMaven(
maven: '3',
mavenLocalRepo: '.repository',
publisherStrategy: 'EXPLICIT',
) {
sh './gradlew initGitSubmodules'
}
}
}
stage('Decompile & apply patches') {
tools {
jdk "OpenJDK 8"
}
steps {
withMaven(
maven: '3',
mavenLocalRepo: '.repository',
publisherStrategy: 'EXPLICIT',
) {
sh '''
./gradlew setupUpstream
./gradlew applyPatches
'''
}
}
}
stage('Build') {
tools {
jdk "OpenJDK 8"
}
steps {
withMaven(
maven: '3',
mavenLocalRepo: '.repository',
publisherStrategy: 'EXPLICIT'
) {
withCredentials([usernamePassword(credentialsId: 'jenkins-deploy', usernameVariable: 'ORG_GRADLE_PROJECT_mavenUsername', passwordVariable: 'ORG_GRADLE_PROJECT_mavenPassword')]) {
sh '''
./gradlew build publish
mkdir -p "./target"
basedir=$(pwd)
paperworkdir="$basedir/Paper/work"
mcver=$(cat "$paperworkdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
patchedJarPath="$basedir/Yatopia-Server/build/libs/yatopia-server-$mcver-R0.1-SNAPSHOT.jar"
vanillaJarPath="$paperworkdir/Minecraft/$mcver/$mcver.jar"
cd "$paperworkdir/Paperclip"
mvn -T 2C clean package -Dmcver="$mcver" -Dpaperjar="$patchedJarPath" -Dvanillajar="$vanillaJarPath" -Dstyle.color=never
cd "$basedir"
cp -v "$paperworkdir/Paperclip/assembly/target/paperclip-$mcver.jar" "./target/yatopia-$mcver-paperclip-b$BUILD_NUMBER.jar"
'''
}
}
}
stage('Archive Jars') {
steps {
archiveArtifacts(artifacts: 'target/*.jar', fingerprint: true)
}
}
post {
always {
cleanWs()
sh 'rm -rf /home/jenkins/workspace/YatopiaMC_Yatopia_ver_1.16.5'
}
}
}
}
}