forked from YatopiaMC/Yatopia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
112 lines (102 loc) · 3.78 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
pipeline {
agent { label 'slave' }
options { timestamps() }
environment {
discord_webhook1 = credentials('yatopia_discord_webhook')
}
stages {
stage('Cleanup') {
tools {
jdk "OpenJDK 8"
}
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'
// sh 'mv ./Paper/work/Minecraft ./ || true'
sh 'rm -fr ./Paper/work/*'
// sh 'mv ./Minecraft ./Paper/work/ || true'
sh 'rm -rf ./Yatopia-API ./Yatopia-Server'
sh 'chmod +x ./gradlew'
sh './gradlew clean'
}
}
stage('Init project & submodules') {
tools {
jdk "OpenJDK 8"
}
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()
}
}
}
stage('Discord Webhook') {
steps {
script {
discordSend description: "Yatopia Jenkins Build", footer: "Yatopia", link: env.BUILD_URL, result: currentBuild.currentResult, title: JOB_NAME, webhookURL: discord_webhook1
}
}
}
}
}