Stop builds killing each other on the same slave

This commit is contained in:
Dan Hawkins 2018-09-17 09:08:28 +01:00
commit 953e3dfc00

View file

@ -4,15 +4,13 @@ def doKillLeftovers() {
sh """
# Killing any processes that may interfere with the next build
# The build system must be setup to do more than one eclipse build concurrently
USER=`whoami`
pgrep -U "${USER}" "eclipse" || true
pgrep -U "${USER}" "eclipsews" || true
pgrep -U "${USER}" "make" || true
pgrep -U "${USER}" "arm-linux" || true
# Don't return an error if the processes don't exist
USER=`whoami`
ps aux | grep "eclipse"
pkill -U "${USER}" -9 eclipse || true
pkill -U "${USER}" -9 eclipsews || true
ps aux | grep "make"
pkill -U "${USER}" -9 make || true
ps aux | grep "arm-linux"
pkill -U "${USER}" -9 ".*arm-linux.*" || true
"""
}
@ -106,42 +104,45 @@ def doImportProjects(ds5folder, toolchainfolder, ds5shellcommand, buildcommand,
// Build and export files
def doBuild(apps, ds5folder, toolchainfolder, ds5shellcommand, buildcommand, sourcefolder, exportfolder = "${WORKSPACE}/bin") {
doKillLeftovers()
addToolchainPath(toolchainfolder)
doImportProjects(ds5folder, toolchainfolder, ds5shellcommand, buildcommand, sourcefolder)
for (appInfo in apps ) {
(build, cleanbuild, project, variants, exportpathlist) = appInfo
if (build) {
if (cleanbuild) {
buildtype = "-cleanBuild"
}
else {
buildtype = "-build"
}
for (build_variant in variants) {
retry(maxprojectbuildretries) { // Eclipse occasionally raises exceptions (rather than the builds failing)
doRegisterToolchain(ds5folder, toolchainfolder)
echo "Build command: ${ds5shellcommand} \'${buildcommand} ${buildtype} \"${project}/${build_variant}\"\'"
if (isUnix()) {
sh """
echo Start time: `date`
${ds5shellcommand} \'${buildcommand} ${buildtype} \"${project}/${build_variant}\"\'
echo End time: `date`
"""
// The lock is being used because it was being found that the doKillLeftovers was affecting other builds
lock(resource: "eclipsebuild_${env.NODE_NAME}") {
doKillLeftovers()
addToolchainPath(toolchainfolder)
doImportProjects(ds5folder, toolchainfolder, ds5shellcommand, buildcommand, sourcefolder)
for (appInfo in apps ) {
(build, cleanbuild, project, variants, exportpathlist) = appInfo
if (build) {
if (cleanbuild) {
buildtype = "-cleanBuild"
}
else {
buildtype = "-build"
}
for (build_variant in variants) {
retry(maxprojectbuildretries) { // Eclipse occasionally raises exceptions (rather than the builds failing)
doRegisterToolchain(ds5folder, toolchainfolder)
echo "Build command: ${ds5shellcommand} \'${buildcommand} ${buildtype} \"${project}/${build_variant}\"\'"
if (isUnix()) {
sh """
echo Start time: `date`
${ds5shellcommand} \'${buildcommand} ${buildtype} \"${project}/${build_variant}\"\'
echo End time: `date`
"""
}
else {
bat """
"%ds5shellcommand%" "%buildcommand%" ${buildtype} "${project}\\${build_variant}"
"""
}
doExport(exportfolder, exportpathlist, "", build_variant)
}
else {
bat """
"%ds5shellcommand%" "%buildcommand%" ${buildtype} "${project}\\${build_variant}"
"""
}
doExport(exportfolder, exportpathlist, "", build_variant)
}
}
}
else {
// Only export if the project has no variants - signifying that there are files to export which have been prebuilt
if (!variants) {
doExport(exportfolder, exportpathlist, project)
else {
// Only export if the project has no variants - signifying that there are files to export which have been prebuilt
if (!variants) {
doExport(exportfolder, exportpathlist, project)
}
}
}
}