diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index 8014f3573..249d24485 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -1640,19 +1640,27 @@ def postBuildWSclean( // Issue: https://issues.jenkins.io/browse/JENKINS-64779 if (context.WORKSPACE != null && !context.WORKSPACE.isEmpty()) { if (cleanWorkspaceAfter) { - context.println 'Cleaning workspace non-hidden files: ' + context.WORKSPACE + '/*' - context.sh(script: 'rm -rf ' + context.WORKSPACE + '/*') + try { + context.println 'Cleaning workspace non-hidden files: ' + context.WORKSPACE + '/*' + context.sh(script: 'rm -rf ' + context.WORKSPACE + '/*') + } catch (e) { + context.println "Warning: Failed to clean workspace non-hidden files ${e}" + } // Clean remaining hidden files using cleanWs try { context.println 'Cleaning workspace hidden files using cleanWs: ' + context.WORKSPACE context.cleanWs notFailBuild: true, disableDeferredWipeout: true, deleteDirs: true } catch (e) { - context.println "Failed to clean ${e}" + context.println "Warning: Failed to clean ${e}" } } else if (cleanWorkspaceBuildOutputAfter) { - context.println 'Cleaning workspace build output files under ' + context.WORKSPACE - batOrSh('rm -rf ' + context.WORKSPACE + '/workspace/build/src/build ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput') + try { + context.println 'Cleaning workspace build output files under ' + context.WORKSPACE + batOrSh('rm -rf ' + context.WORKSPACE + '/workspace/build/src/build ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput') + } catch (e) { + context.println "Warning: Failed to clean workspace build output files ${e}" + } } } else { context.println 'Warning: Unable to clean workspace as context.WORKSPACE is null/empty' @@ -1687,6 +1695,7 @@ def buildScriptsAssemble( batOrSh "rm -rf ${base_path}/jdk/modules/jdk.jpackage/jdk/jpackage/internal/resources/*" } context.stage('assemble') { + try { // This would ideally not be required but it's due to lack of UID mapping in windows containers if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE) { context.bat('chmod -R a+rwX ' + '/cygdrive/c/workspace/openjdk-build/workspace/build/src/build/*') @@ -1756,7 +1765,9 @@ def buildScriptsAssemble( } throw new Exception("[ERROR] Build archive timeout (${buildTimeouts.BUILD_ARCHIVE_TIMEOUT} HOURS) has been reached. Exiting...") } + } finally { postBuildWSclean(cleanWorkspaceAfter, cleanWorkspaceBuildOutputAfter) + } } // context.stage('assemble') } // End of buildScriptsAssemble() 1643-1765 @@ -2195,10 +2206,21 @@ def buildScriptsAssemble( try { context.cleanWs notFailBuild: true } catch (e) { - context.println "Failed to clean ${e}" + context.println "Warning: Failed to clean ${e}" } cleanWorkspace = false } + // For Windows build also clean alternative(shorter path length) workspace + if ( buildConfig.TARGET_OS == 'windows' ) { + context.ws(workspace) { + try { + context.println "Windows build cleaning" + context.WORKSPACE + context.cleanWs notFailBuild: true + } catch (e) { + context.println "Warning: Failed to clean ${e}" + } + } + } } } catch (FlowInterruptedException e) { throw new Exception("[ERROR] Controller clean workspace timeout (${buildTimeouts.CONTROLLER_CLEAN_TIMEOUT} HOURS) has been reached. Exiting...") diff --git a/pipelines/build/prTester/pr_test_pipeline.groovy b/pipelines/build/prTester/pr_test_pipeline.groovy index 084f21a95..c7007a13b 100644 --- a/pipelines/build/prTester/pr_test_pipeline.groovy +++ b/pipelines/build/prTester/pr_test_pipeline.groovy @@ -163,6 +163,7 @@ class PullRequestTestPipeline implements Serializable { context.booleanParam(name: 'enableInstallers', value: false), // never need this enabled in pr-test context.booleanParam(name: 'useAdoptBashScripts', value: false), // should not use defaultsJson but adoptDefaultsJson context.booleanParam(name: 'keepReleaseLogs', value: false), // never need this enabled in pr-tester + context.booleanParam(name: 'cleanWorkspace', value: true), // always clean prtester workspace before the build context.booleanParam(name: 'cleanWorkspaceAfterBuild', value: true) // always clean prtester workspace after the build ] } catch (err) {