Set build to unstable if tests fail.

This commit is contained in:
/dev/root 2017-05-31 23:00:56 +02:00
parent 5327a4f272
commit 7805d7f356

87
Jenkinsfile vendored
View File

@ -175,7 +175,7 @@ def doUnitTests(name) {
// Returns the IW4x executable branch to use // Returns the IW4x executable branch to use
def iw4xExecutableBranch() { def iw4xExecutableBranch() {
try { try {
return IW4X_EXECUTABLE_BRANCH; return IW4X_EXECUTABLE_BRANCH;
} catch(MissingPropertyException) { } catch(MissingPropertyException) {
return "master"; return "master";
} }
@ -195,8 +195,8 @@ gitlabBuilds(builds: ["Checkout & Versioning", "Build", "Testing", "Archiving"])
jobWorkspace("versioning") { jobWorkspace("versioning") {
if (env.BRANCH_NAME == 'master') if (env.BRANCH_NAME == 'master')
{ {
echo 'Reset build environment' echo 'Reset build environment'
deleteDir() deleteDir()
} }
retry(5) { retry(5) {
@ -241,46 +241,51 @@ gitlabBuilds(builds: ["Checkout & Versioning", "Build", "Testing", "Archiving"])
stage("Testing") { stage("Testing") {
gitlabCommitStatus("Testing") { gitlabCommitStatus("Testing") {
executions = [:] executions = [:]
timeout(10) { try {
for (int i = 0; i < testing.size(); i++) { timeout(10) {
def entry = testing.get(i) for (int i = 0; i < testing.size(); i++) {
def entry = testing.get(i)
def testName = entry[0] def testName = entry[0]
def test = entry[1] def test = entry[1]
executions["$testName on Windows"] = { executions["$testName on Windows"] = {
node("windows") { node("windows") {
jobWorkspace(test.WorkspaceID) { jobWorkspace(test.WorkspaceID) {
doUnitTests(test.StashName) doUnitTests(test.StashName)
} }
} }
} }
executions["$testName on Linux"] = { executions["$testName on Linux"] = {
node("docker && linux && amd64") { node("docker && linux && amd64") {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) { wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
try { try {
def image = null def image = null
dir("src") { dir("src") {
unstash "jenkins-files" unstash "jenkins-files"
image = docker.build("github.com/IW4x/iw4x-client-testing-wine32", "--rm --force-rm -f jenkins/wine32.Dockerfile jenkins") image = docker.build("github.com/IW4x/iw4x-client-testing-wine32", "--rm --force-rm -f jenkins/wine32.Dockerfile jenkins")
deleteDir() deleteDir()
} }
image.inside { image.inside {
doUnitTests(test.StashName) doUnitTests(test.StashName)
} }
} catch (Exception e) { } catch (Exception e) {
if (isUnix()) { if (isUnix()) {
manager.buildUnstable() manager.buildUnstable()
manager.addWarningBadge "$testName unit test failed on Linux" manager.addWarningBadge "$testName unit test failed on Linux"
} else { } else {
throw e throw e
} }
} }
} }
} }
} }
} }
parallel executions parallel executions
}
} catch (Exception e) {
manager.buildUnstable()
manager.addWarningBadge "Tests ran too long."
} }
} }
} }