From 08bda243a2406c3ccefdde389cc4da2fa7c7b509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Fri, 7 Jun 2019 22:19:33 +0200 Subject: [PATCH] Use a label for MINGW/OSX builds in PR By setting the label CI/Build OSX (or MINGW), Jenkins will now build this PR also with the selected target(s). Useful if you do not have access to a Mac machine and want to make sure you don't break it. --- .CI/common.groovy | 30 ++++++++++++++++++++++++++---- Jenkinsfile | 26 ++++++++++++++++++-------- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/.CI/common.groovy b/.CI/common.groovy index 55a6c62c811..52fe9b0429c 100644 --- a/.CI/common.groovy +++ b/.CI/common.groovy @@ -20,7 +20,7 @@ def numPhysicalCPU() { if (env.JENKINS_NUM_PHYSICAL_CPU) { return env.JENKINS_NUM_PHYSICAL_CPU } - + if (isWindows()) { return env.NUMBER_OF_PROCESSORS.toInteger() / 2 ?: 1 @@ -98,7 +98,7 @@ void partest(cache=true, extraArgs='') { } else { sh "rm -f omc-diff.skip && ${makeCommand()} -C testsuite/difftool clean && ${makeCommand()} --output-sync -C testsuite/difftool" sh 'build/bin/omc-diff -v1.4' - + sh ("""#!/bin/bash -x ulimit -t 1500 ulimit -v 6291456 # Max 6GB per process @@ -180,7 +180,7 @@ void buildOMC(CC, CXX, extraFlags) { ) > buildOMCWindows.sh set MSYSTEM=MINGW64 - set MSYS2_PATH_TYPE=inherit + set MSYS2_PATH_TYPE=inherit %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath ' ${WORKSPACE} '` && chmod +x buildOMCWindows.sh && ./buildOMCWindows.sh && rm -f ./buildOMCWindows.sh" """) } else { @@ -209,7 +209,7 @@ void buildGUI(stash) { ) > buildGUIWindows.sh set MSYSTEM=MINGW64 - set MSYS2_PATH_TYPE=inherit + set MSYS2_PATH_TYPE=inherit %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath ' ${WORKSPACE} '` && chmod +x buildGUIWindows.sh && ./buildGUIWindows.sh && rm -f ./buildGUIWindows.sh" """) } else { @@ -284,4 +284,26 @@ def makeCommand() { return env.GMAKE ?: "make" } +def shouldWeBuildOSX() { + if (env.CHANGE_ID) { + if (pullRequest.labels.contains("CI/Build OSX")) { + return true + } + } + return params.BUILD_OSX +} + +def shouldWeBuildMINGW() { + if (env.CHANGE_ID) { + if (pullRequest.labels.contains("CI/Build MINGW")) { + return true + } + } + return params.BUILD_MINGW +} + +def isPR() { + return env.CHANGE_ID ? true : false +} + return this diff --git a/Jenkinsfile b/Jenkinsfile index 591f6674d7e..cbc8f5a3436 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,7 @@ def common +def shouldWeBuildOSX +def shouldWeBuildMINGW +def isPR pipeline { agent none options { @@ -24,8 +27,15 @@ pipeline { def buildNumber = env.BUILD_NUMBER as int if (buildNumber > 1) milestone(buildNumber - 1) milestone(buildNumber) + isPR = true + } else { + isPR = false } common = load("${env.workspace}/.CI/common.groovy") + shouldWeBuildOSX = common.shouldWeBuildOSX() + print "shouldWeBuildOSX: ${shouldWeBuildOSX}" + shouldWeBuildMINGW = common.shouldWeBuildMINGW() + print "shouldWeBuildMINGW: ${shouldWeBuildMINGW}" } } } @@ -68,7 +78,8 @@ pipeline { } } when { - expression { params.BUILD_OSX } + beforeAgent true + expression { shouldWeBuildOSX } } environment { RUNTESTDB = '/Users/hudson/jenkins-cache/runtest/' @@ -94,7 +105,8 @@ pipeline { } } when { - expression { params.BUILD_MINGW } + beforeAgent true + expression { shouldWeBuildMINGW } } environment { RUNTESTDB = '/c/dev/' @@ -486,9 +498,8 @@ pipeline { } } when { - not { - changeRequest() - } + beforeAgent true + expression { not isPR } } steps { unstash 'compliance' @@ -505,9 +516,8 @@ pipeline { } } when { - not { - changeRequest() - } + beforeAgent true + expression { not isPR } } steps { unstash 'usersguide'