Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
ci-minecraft-forge-server-test
Advanced tools
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.
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.
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'
}
}
}
}
The following is an example code that use this library.
import { readFile } from 'fs';
import { join, resolve as pathResolve } from 'path';
import { exit } from 'process';
import { CIMinecraftForgeServerTest } from 'ci-minecraft-forge-server-test';
const buildLibsDirectory = pathResolve('..', 'build', 'libs');
const serverDirectory = pathResolve('..', 'run');
// Minecraft and Forge versions
let minecraftVersion = null;
let forgeVersion = null;
// Path to mod .jar file
let modFilepath = null;
// Get the Minecraft, Forge and mod versions from build.gradle
function getVersions() {
return new Promise((resolve, reject) => {
readFile(pathResolve('..', 'build.gradle'), 'UTF-8', (err, data) => {
if (err != null) {
reject(err);
return;
}
let modVersion = null;
data
.split('\n')
.forEach((line, i) => {
if (line.startsWith('def')) {
const varName = line.split(' ')[1];
const varValue = line.split('\'')[1];
if (varName === 'mcVersion') {
minecraftVersion = varValue;
} else if (varName === 'forgeVersion') {
forgeVersion = varValue;
} else if (varName === 'modVersion') {
modVersion = varValue;
}
}
});
if (minecraftVersion == null || forgeVersion == null) {
reject('Could not find Minecraft and/or Forge version');
return;
}
if (modVersion == null) {
reject('Could not find mod version');
return;
}
modFilepath = join(buildLibsDirectory, `ModName-mc${minecraftVersion}-${modVersion}.jar`);
resolve();
});
});
}
// Create instance of ci-minecraft-forge-server-test
const tester = new CIMinecraftForgeServerTest();
getVersions()
.then(() => {
tester
.setVersions(minecraftVersion, forgeVersion) // Set versions
//.acceptEULA() // Accept Minecraft's EULA (commented out to prevent blindingly accepting by copy/paste)
.useServerProperties() // Use ci-minecraft-forge-server-test's server.properties file
.setServerDirectory(serverDirectory) // Set the directory for the server
.addLocalMod(modFilepath) // Add the mod
.addCommand('forge tps'); // Add command to run
return tester.installForge() // Install Forge
.then(() => tester.runServer()); // Run the server
})
.catch(err => {
console.error(err);
exit(1);
});
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).
FAQs
Minecraft Forge server testing for CI
We found that ci-minecraft-forge-server-test demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.