From 904ffdc6263bfe12353e7313d32d56789b06a209 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 10 May 2024 10:44:02 +0100 Subject: [PATCH] Ensure any old openjdk build directory is removed before building Signed-off-by: Andrew Leonard --- .../build/common/openjdk_build_pipeline.groovy | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index 75d9332d9..75d57edba 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -1533,6 +1533,24 @@ class Build { } } + // Always clean any previous "openjdk_build_dir" output, possibly from any previous aborted build.. + try { + try { + context.timeout(time: buildTimeouts.NODE_CLEAN_TIMEOUT, unit: 'HOURS') { + if (context.WORKSPACE != null && !context.WORKSPACE.isEmpty()) { + context.println 'Removing workspace openjdk build directory: ' + openjdk_build_dir + context.sh(script: 'rm -rf ' + openjdk_build_dir) + } else { + context.println 'Warning: Unable to remove workspace openjdk build directory as context.WORKSPACE is null/empty' + } + } + } catch (FlowInterruptedException e) { + throw new Exception("[ERROR] Remove workspace openjdk build directory timeout (${buildTimeouts.NODE_CLEAN_TIMEOUT} HOURS) has been reached. Exiting...") + } + } catch (e) { + context.println "[WARNING] Failed to remove workspace openjdk build directory: ${e}" + } + try { context.timeout(time: buildTimeouts.NODE_CHECKOUT_TIMEOUT, unit: 'HOURS') { if (useAdoptShellScripts) {