2016-09-12 18:33:00 -04:00
|
|
|
#!groovy
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is our new pipeline script to do all of the building in, of and around IW4x.
|
|
|
|
|
|
|
|
Here's what it is supposed to do:
|
|
|
|
|
|
|
|
- Make sure Modern Warfare 2 is installed (CI should provide the folder like a custom tool)
|
|
|
|
- Check out code from iw4x-data
|
|
|
|
- Build the IW4x client library (this code repository)
|
|
|
|
- Use iw4x.exe from the iw4x-data repository in order to build the zone files in iw4x-data
|
|
|
|
- Package the IW4x client with the newly built data files
|
|
|
|
|
|
|
|
At this point it is done building everything, however afterwards we want the build server to
|
|
|
|
also push the newly built files to an update repository, depending on the branch we're on.
|
|
|
|
|
|
|
|
- For "develop", release to the "iw4x-dev" branch on the repository server.
|
|
|
|
- For "master", release to the "iw4x" branch on the repository server.
|
|
|
|
|
|
|
|
I'm looking into how the logic of pipelining works in detail before deciding on whether to
|
|
|
|
throw in the IW4x Updater and the IW4x Node binaries in as well or not.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Note that this is just a rewrite of the jobs as they are currently set up on the production
|
|
|
|
Jenkins server. This will allow every developer to tinker around with how the build process
|
|
|
|
is set up. For those who want to play around with this, here's a bit of information:
|
|
|
|
|
|
|
|
- This is a Groovy script. Essentially Java but with less bullshit (like brackets and verbose writing).
|
|
|
|
- This gets directly translated into a Jenkins pipeline.
|
|
|
|
- If you have no idea how to handle scripts, get your hands off this file.
|
|
|
|
- If you do not use Jenkins, get your hands off this file.
|
|
|
|
- If you fuck this script up, I will kill you.
|
|
|
|
*/
|
|
|
|
|
2016-09-12 19:41:39 -04:00
|
|
|
import groovy.transform.Field
|
|
|
|
|
2016-09-12 18:33:00 -04:00
|
|
|
@Field def configurations = [
|
2016-09-17 13:08:00 -04:00
|
|
|
"Debug": [
|
|
|
|
WorkspaceID: "build@debug",
|
|
|
|
StashName: "iw4x-debug",
|
|
|
|
MSBuildConfiguration: "Debug",
|
|
|
|
PremakeArgs: "",
|
|
|
|
Archive: true,
|
|
|
|
],
|
|
|
|
"Release": [
|
|
|
|
WorkspaceID: "build@release",
|
|
|
|
StashName: "iw4x-release",
|
|
|
|
MSBuildConfiguration: "Release",
|
|
|
|
PremakeArgs: "",
|
|
|
|
Archive: true,
|
|
|
|
],
|
|
|
|
"Release with unit tests": [
|
|
|
|
WorkspaceID: "build@release+unittests",
|
|
|
|
StashName: "iw4x-release-unittests",
|
|
|
|
MSBuildConfiguration: "Release",
|
|
|
|
PremakeArgs: "--force-unit-tests",
|
|
|
|
Archive: false,
|
|
|
|
],
|
|
|
|
].collect {k, v -> [k, v]}
|
|
|
|
|
|
|
|
@Field def testing = [
|
|
|
|
"Debug": [
|
|
|
|
WorkspaceID: "testing@debug",
|
|
|
|
StashName: "iw4x-debug",
|
|
|
|
],
|
|
|
|
"Release": [
|
|
|
|
WorkspaceID: "testing@release",
|
|
|
|
StashName: "iw4x-release-unittests",
|
|
|
|
],
|
|
|
|
].collect {k, v -> [k, v]}
|
|
|
|
|
|
|
|
def jobWorkspace(id, f) {
|
|
|
|
ws("workspace/${env.JOB_NAME}@$id", f)
|
|
|
|
}
|
2016-09-12 18:33:00 -04:00
|
|
|
|
2016-09-12 21:07:56 -04:00
|
|
|
def useShippedPremake(f) {
|
|
|
|
def premakeHome = "${pwd()}\\tools"
|
|
|
|
|
|
|
|
withEnv(["PATH+=${premakeHome}"], f)
|
|
|
|
}
|
|
|
|
|
2016-09-13 16:47:27 -04:00
|
|
|
def getIW4xExecutable() {
|
2016-09-13 17:07:48 -04:00
|
|
|
step([
|
2016-09-13 16:47:27 -04:00
|
|
|
$class: 'CopyArtifact',
|
|
|
|
filter: '*',
|
|
|
|
fingerprintArtifacts: true,
|
2016-10-02 18:53:08 -04:00
|
|
|
projectName: 'iw4x/iw4x-executable/' + iw4xExecutableBranch,
|
2016-09-13 16:47:27 -04:00
|
|
|
selector: [
|
|
|
|
$class: 'TriggeredBuildSelector',
|
|
|
|
allowUpstreamDependencies: false,
|
|
|
|
fallbackToLastSuccessful: true,
|
|
|
|
upstreamFilterStrategy: 'UseGlobalSetting'
|
|
|
|
]
|
2016-09-13 17:07:48 -04:00
|
|
|
])
|
2016-09-13 16:47:27 -04:00
|
|
|
}
|
|
|
|
|
2016-09-12 18:33:00 -04:00
|
|
|
// This will build the IW4x client.
|
|
|
|
// We need a Windows Server with Visual Studio 2015, Premake5 and Git on it.
|
2016-09-17 13:08:00 -04:00
|
|
|
def doBuild(cfg) {
|
2016-09-12 18:33:00 -04:00
|
|
|
node("windows") {
|
2016-09-17 13:08:00 -04:00
|
|
|
jobWorkspace(cfg.WorkspaceID) {
|
2016-09-12 21:17:02 -04:00
|
|
|
checkout scm
|
|
|
|
|
|
|
|
useShippedPremake {
|
|
|
|
def outputDir = pwd()
|
|
|
|
def msbuild = tool "Microsoft.NET MSBuild 14.0"
|
2016-09-17 13:08:00 -04:00
|
|
|
bat "premake5 vs2015 ${cfg.PremakeArgs}"
|
|
|
|
bat "\"${msbuild}\" build\\iw4x.sln \"/p:OutDir=$outputDir\\\\\" \"/p:Configuration=${cfg.MSBuildConfiguration}\""
|
2016-09-12 21:17:02 -04:00
|
|
|
}
|
2016-09-12 18:33:00 -04:00
|
|
|
|
2016-09-17 13:08:00 -04:00
|
|
|
stash name: "${cfg.StashName}", includes: "*.dll,*.pdb"
|
2016-09-12 18:33:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-12 20:54:46 -04:00
|
|
|
// This will run the unit tests for IW4x.
|
|
|
|
// We need a Windows Server with MW2 on it.
|
2016-09-15 15:09:40 -04:00
|
|
|
def doUnitTests(name) {
|
2016-09-15 14:42:59 -04:00
|
|
|
mw2dir = tool "Modern Warfare 2"
|
|
|
|
|
|
|
|
unstash "$name"
|
|
|
|
|
|
|
|
// Get installed localization for correct zonefiles directory junction
|
|
|
|
def localization = readFile("$mw2dir/localization.txt").split("\r?\n")[0]
|
|
|
|
|
|
|
|
try {
|
|
|
|
timeout(time: 180, unit: "MINUTES") {
|
|
|
|
// Set up environment
|
|
|
|
if (isUnix()) {
|
|
|
|
sh """
|
|
|
|
mkdir -p zone
|
|
|
|
for f in main zone/dlc \"zone/$localization\"; do
|
|
|
|
ln -sfv \"$mw2dir/\$f\" \"\$f\"
|
|
|
|
done
|
|
|
|
for f in \"$mw2dir\"/*.dll \"$mw2dir\"/*.txt \"$mw2dir\"/*.bmp; do
|
|
|
|
ln -sfv \"\$f\" \"\$(basename \"\$f\")\"
|
|
|
|
done
|
|
|
|
"""
|
|
|
|
} else {
|
2016-09-12 20:54:46 -04:00
|
|
|
bat """
|
2016-09-15 14:42:59 -04:00
|
|
|
mklink /J \"main\" \"$mw2dir\\main\"
|
|
|
|
mkdir \"zone\"
|
|
|
|
mklink /J \"zone\\dlc\" \"$mw2dir\\zone\\dlc\"
|
|
|
|
mklink /J \"zone\\$localization\" \"$mw2dir\\zone\\$localization\"
|
|
|
|
copy /y \"$mw2dir\\*.dll\"
|
|
|
|
copy /y \"$mw2dir\\*.txt\"
|
|
|
|
copy /y \"$mw2dir\\*.bmp\"
|
2016-09-12 20:54:46 -04:00
|
|
|
"""
|
|
|
|
}
|
2016-09-15 14:42:59 -04:00
|
|
|
|
|
|
|
// Run tests
|
|
|
|
getIW4xExecutable()
|
|
|
|
if (isUnix()) {
|
2016-09-28 14:55:17 -04:00
|
|
|
sh "WINEDEBUG=warn+all wine-wrapper iw4x.exe -tests"
|
2016-09-15 14:42:59 -04:00
|
|
|
} else {
|
|
|
|
bat "iw4x.exe -tests"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
// In all cases make sure to at least remove the directory junctions!
|
|
|
|
if (!isUnix()) {
|
|
|
|
bat """
|
|
|
|
rmdir \"main\"
|
|
|
|
rmdir \"zone\\dlc\"
|
|
|
|
rmdir \"zone\\$localization\"
|
|
|
|
"""
|
2016-09-12 20:54:46 -04:00
|
|
|
}
|
2016-09-15 14:42:59 -04:00
|
|
|
deleteDir()
|
2016-09-12 20:54:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-14 16:43:29 -04:00
|
|
|
// Job properties
|
2016-09-14 16:52:59 -04:00
|
|
|
properties([
|
2016-09-14 16:43:29 -04:00
|
|
|
[$class: "GitLabConnectionProperty", gitLabConnection: "sr0"]
|
2016-09-14 16:52:59 -04:00
|
|
|
])
|
2016-09-14 16:43:29 -04:00
|
|
|
|
2016-10-02 18:53:08 -04:00
|
|
|
|
2016-09-14 16:33:19 -04:00
|
|
|
gitlabBuilds(builds: ["Checkout & Versioning", "Build", "Testing", "Archiving"]) {
|
|
|
|
// First though let's give this build a proper name
|
|
|
|
stage("Checkout & Versioning") {
|
|
|
|
gitlabCommitStatus("Checkout & Versioning") {
|
|
|
|
node("windows") {
|
2016-09-17 13:08:00 -04:00
|
|
|
jobWorkspace("versioning") {
|
|
|
|
checkout scm
|
2016-09-12 20:55:08 -04:00
|
|
|
|
2016-09-17 13:08:00 -04:00
|
|
|
useShippedPremake {
|
|
|
|
def version = bat(returnStdout: true, script: '@premake5 version').split("\r?\n")[1]
|
2016-09-12 20:55:08 -04:00
|
|
|
|
2016-09-17 13:08:00 -04:00
|
|
|
currentBuild.setDisplayName "$version (#${env.BUILD_NUMBER})"
|
|
|
|
}
|
2016-09-14 16:33:19 -04:00
|
|
|
}
|
2016-09-14 15:13:14 -04:00
|
|
|
}
|
2016-09-12 21:07:56 -04:00
|
|
|
}
|
2016-09-12 21:03:35 -04:00
|
|
|
}
|
2016-09-12 20:55:08 -04:00
|
|
|
|
2016-09-14 16:33:19 -04:00
|
|
|
// For each available configuration generate a normal build and a unit test build.
|
|
|
|
stage("Build") {
|
|
|
|
gitlabCommitStatus("Build") {
|
|
|
|
def executions = [:]
|
2016-09-17 13:08:00 -04:00
|
|
|
for (int i = 0; i < configurations.size(); i++) {
|
|
|
|
def entry = configurations[i]
|
|
|
|
|
|
|
|
def configName = entry[0]
|
|
|
|
def config = entry[1]
|
|
|
|
|
|
|
|
executions[configName] = {
|
|
|
|
node("windows") {
|
|
|
|
jobWorkspace(config.WorkspaceID) {
|
|
|
|
doBuild(config)
|
|
|
|
}
|
|
|
|
}
|
2016-09-14 16:33:19 -04:00
|
|
|
}
|
2016-09-14 15:13:14 -04:00
|
|
|
}
|
2016-09-14 16:33:19 -04:00
|
|
|
parallel executions
|
2016-09-12 21:03:35 -04:00
|
|
|
}
|
2016-09-12 18:33:00 -04:00
|
|
|
}
|
|
|
|
|
2016-09-14 16:33:19 -04:00
|
|
|
// Run unit tests on each configuration.
|
|
|
|
stage("Testing") {
|
|
|
|
gitlabCommitStatus("Testing") {
|
|
|
|
executions = [:]
|
2016-09-17 13:08:00 -04:00
|
|
|
for (int i = 0; i < testing.size(); i++) {
|
|
|
|
def entry = testing.get(i)
|
|
|
|
|
|
|
|
def testName = entry[0]
|
|
|
|
def test = entry[1]
|
|
|
|
|
|
|
|
executions["$testName on Windows"] = {
|
2016-09-15 02:25:12 -04:00
|
|
|
node("windows") {
|
2016-09-17 13:08:00 -04:00
|
|
|
jobWorkspace(test.WorkspaceID) {
|
|
|
|
doUnitTests(test.StashName)
|
2016-09-15 14:42:59 -04:00
|
|
|
}
|
2016-09-15 02:25:12 -04:00
|
|
|
}
|
|
|
|
}
|
2016-09-17 13:08:00 -04:00
|
|
|
executions["$testName on Linux"] = {
|
2016-09-15 02:25:12 -04:00
|
|
|
node("docker && linux && amd64") {
|
2016-09-15 16:52:29 -04:00
|
|
|
try {
|
|
|
|
def image = null
|
|
|
|
dir("src") {
|
|
|
|
checkout scm
|
|
|
|
image = docker.build("github.com/IW4x/iw4x-client-testing-wine32", "--rm --force-rm -f jenkins/wine32.Dockerfile jenkins")
|
|
|
|
deleteDir()
|
|
|
|
}
|
|
|
|
image.inside {
|
2016-09-17 13:08:00 -04:00
|
|
|
doUnitTests(test.StashName)
|
2016-09-15 16:52:29 -04:00
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
if (isUnix()) {
|
|
|
|
manager.buildUnstable()
|
2016-09-17 13:08:00 -04:00
|
|
|
manager.addWarningBadge "$testName unit test failed on Linux"
|
2016-09-15 16:52:29 -04:00
|
|
|
} else {
|
|
|
|
throw e
|
|
|
|
}
|
2016-09-15 02:25:12 -04:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 16:33:19 -04:00
|
|
|
}
|
2016-09-14 15:13:14 -04:00
|
|
|
}
|
2016-09-15 16:52:29 -04:00
|
|
|
parallel executions
|
2016-09-12 21:03:35 -04:00
|
|
|
}
|
2016-09-12 20:54:46 -04:00
|
|
|
}
|
2016-09-12 20:56:00 -04:00
|
|
|
|
2016-09-14 16:33:19 -04:00
|
|
|
// Collect all the binaries and give each configuration its own subfolder
|
|
|
|
stage("Archiving") {
|
|
|
|
gitlabCommitStatus("Archiving") {
|
|
|
|
node("windows") { // any node will do
|
2016-09-17 13:08:00 -04:00
|
|
|
jobWorkspace("archiving") {
|
2016-09-14 16:33:19 -04:00
|
|
|
try {
|
2016-09-17 13:08:00 -04:00
|
|
|
for (int i = 0; i < configurations.size(); i++) {
|
|
|
|
def entry = configurations[i]
|
|
|
|
|
|
|
|
def configName = entry[0]
|
|
|
|
def config = entry[1]
|
|
|
|
|
|
|
|
if (config.Archive) {
|
|
|
|
dir(configName) {
|
|
|
|
unstash config.StashName
|
|
|
|
}
|
2016-09-14 16:33:19 -04:00
|
|
|
}
|
2016-09-14 15:13:14 -04:00
|
|
|
}
|
2016-09-14 16:33:19 -04:00
|
|
|
archiveArtifacts artifacts: "**/*.dll,**/*.pdb", fingerprint: true
|
|
|
|
} finally {
|
|
|
|
deleteDir()
|
2016-09-14 02:35:57 -04:00
|
|
|
}
|
|
|
|
}
|
2016-09-12 21:03:35 -04:00
|
|
|
}
|
2016-09-12 20:56:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|