ci-minecraft-forge-server-test
Tool for testing Minecraft Forge servers as part of testing on CI servers.
This handles installing Minecraft Forge, copy/download mods, starting the server, running commands and stopping the server again.
How to
This is only a library and will need to be executed by other code (See example code below), as different projects will have different requirements for the server testing.
To run the code on a Jenkins CI server, simply add sh 'npm install'
and sh 'npm start'
as a step in your Jenkinsfile
.
Tip: You can archive the log file as a post
action.
Example Jenkinsfile
pipeline {
agent any
options {
timeout(time: 30, unit: 'MINUTES')
}
tools {
jdk 'jdk_8u144'
nodejs 'node_8.4.0'
}
stages {
stage('Prepare') {
steps {
sh 'chmod +x gradlew'
sh './gradlew setupCiWorkspace clean'
}
}
stage('Build') {
steps {
sh './gradlew build jar'
}
}
stage('Run Server Test') {
steps {
dir('serverTest') {
sh 'npm update'
sh 'npm start'
}
}
post {
always {
archiveArtifacts 'run/logs/fml-server-latest.log'
}
}
}
stage('Archive') {
steps {
archiveArtifacts 'build/libs/*.jar'
fingerprint 'build/libs/*.jar'
}
}
}
}
Example code
The following is an example code that use this library.
;;; ; ;; // Minecraft and Forge versions;;// Path to mod .jar file; // Get the Minecraft, Forge and mod versions from build.gradle // Create instance of ci-minecraft-forge-server-test;getVersions .then .catch;
For this to work, the minecraft/forge/mod versions must be defined in the build.gradle
file.
def mcVersion = '1.12'def forgeVersion = '14.21.1.2387'def modVersion = '1.0.0'
When the server is started it executes forge tps
before executing stop
(automaticly done by the library).