From 4c1a1f8d4098a01652c7be7dc1052ca10ad496d2 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Tue, 17 Dec 2024 15:12:21 +0000 Subject: [PATCH 1/9] Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard --- pipelines/build/common/openjdk_build_pipeline.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index 8014f3573..a78d63e8b 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -2199,6 +2199,17 @@ def buildScriptsAssemble( } cleanWorkspace = false } + // For Windows docker build also clean alternative workspace + if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) { + context.ws(workspace) { + try { + context.println "Windows docker build cleaning" + context.WORKSPACE + context.cleanWs notFailBuild: true + } catch (e) { + context.println "Failed to clean ${e}" + } + } + } } } catch (FlowInterruptedException e) { throw new Exception("[ERROR] Controller clean workspace timeout (${buildTimeouts.CONTROLLER_CLEAN_TIMEOUT} HOURS) has been reached. Exiting...") From 86d6212439892e0a822ca9cddfd8f7f1d10b8967 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Tue, 17 Dec 2024 15:16:35 +0000 Subject: [PATCH 2/9] Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard --- pipelines/build/common/openjdk_build_pipeline.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index a78d63e8b..b5212a4a7 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -2199,11 +2199,11 @@ def buildScriptsAssemble( } cleanWorkspace = false } - // For Windows docker build also clean alternative workspace - if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) { + // For Windows build also clean alternative workspace + if ( buildConfig.TARGET_OS == 'windows' ) { context.ws(workspace) { try { - context.println "Windows docker build cleaning" + context.WORKSPACE + context.println "Windows build cleaning" + context.WORKSPACE context.cleanWs notFailBuild: true } catch (e) { context.println "Failed to clean ${e}" From 83da0660d8b26df48d468bca31e4cb8b83a0b1a4 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Wed, 18 Dec 2024 09:10:02 +0000 Subject: [PATCH 3/9] Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard --- .../common/openjdk_build_pipeline.groovy | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index b5212a4a7..07149088a 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -1640,8 +1640,12 @@ 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 "Failed to clean workspace non-hidden files ${e}" + } // Clean remaining hidden files using cleanWs try { @@ -1651,8 +1655,12 @@ def postBuildWSclean( context.println "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 "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 @@ -2199,7 +2210,7 @@ def buildScriptsAssemble( } cleanWorkspace = false } - // For Windows build also clean alternative workspace + // For Windows build also clean alternative(shorter path length) workspace if ( buildConfig.TARGET_OS == 'windows' ) { context.ws(workspace) { try { From 76f571e1a9e6d1917b5523c9e8f48e8d5108ab69 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Wed, 18 Dec 2024 09:19:28 +0000 Subject: [PATCH 4/9] Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard --- pipelines/build/prTester/pr_test_pipeline.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/pipelines/build/prTester/pr_test_pipeline.groovy b/pipelines/build/prTester/pr_test_pipeline.groovy index 084f21a95..0d4c8ef89 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) { From 638c1a9b9af156dee8c0e3e6a3dff097ba66d408 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Wed, 18 Dec 2024 09:31:26 +0000 Subject: [PATCH 5/9] Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard --- pipelines/build/prTester/pr_test_pipeline.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/build/prTester/pr_test_pipeline.groovy b/pipelines/build/prTester/pr_test_pipeline.groovy index 0d4c8ef89..c7007a13b 100644 --- a/pipelines/build/prTester/pr_test_pipeline.groovy +++ b/pipelines/build/prTester/pr_test_pipeline.groovy @@ -163,7 +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: '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) { From 5af4e6abaf75cc0f80a8945ccbddf884c1fc9452 Mon Sep 17 00:00:00 2001 From: Andrew Leonard <31470007+andrew-m-leonard@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:54:29 +0000 Subject: [PATCH 6/9] Update pipelines/build/common/openjdk_build_pipeline.groovy Co-authored-by: Stewart X Addison <6487691+sxa@users.noreply.github.com> --- pipelines/build/common/openjdk_build_pipeline.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index 07149088a..ef4bbd322 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -1644,7 +1644,7 @@ def postBuildWSclean( context.println 'Cleaning workspace non-hidden files: ' + context.WORKSPACE + '/*' context.sh(script: 'rm -rf ' + context.WORKSPACE + '/*') } catch (e) { - context.println "Failed to clean workspace non-hidden files ${e}" + context.println "ERROR: Failed to clean workspace non-hidden files ${e}" } // Clean remaining hidden files using cleanWs From 6525068f4d3041e79b5feeb2323d0cee48e6cb0d Mon Sep 17 00:00:00 2001 From: Andrew Leonard <31470007+andrew-m-leonard@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:54:38 +0000 Subject: [PATCH 7/9] Update pipelines/build/common/openjdk_build_pipeline.groovy Co-authored-by: Stewart X Addison <6487691+sxa@users.noreply.github.com> --- pipelines/build/common/openjdk_build_pipeline.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index ef4bbd322..78a08f6aa 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -1659,7 +1659,7 @@ def postBuildWSclean( 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 "Failed to clean workspace build output files ${e}" + context.println "ERROR: Failed to clean workspace build output files ${e}" } } } else { From 1828de5648f129e1733a963e11281a5504a37d17 Mon Sep 17 00:00:00 2001 From: Andrew Leonard <31470007+andrew-m-leonard@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:54:45 +0000 Subject: [PATCH 8/9] Update pipelines/build/common/openjdk_build_pipeline.groovy Co-authored-by: Stewart X Addison <6487691+sxa@users.noreply.github.com> --- pipelines/build/common/openjdk_build_pipeline.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index 78a08f6aa..3d1f99be1 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -2217,7 +2217,7 @@ def buildScriptsAssemble( context.println "Windows build cleaning" + context.WORKSPACE context.cleanWs notFailBuild: true } catch (e) { - context.println "Failed to clean ${e}" + context.println "ERROR: Failed to clean ${e}" } } } From edc2bb11c0578ef24d510278c702e7abecdee850 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Wed, 18 Dec 2024 10:39:49 +0000 Subject: [PATCH 9/9] Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard --- pipelines/build/common/openjdk_build_pipeline.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index 3d1f99be1..249d24485 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -1644,7 +1644,7 @@ def postBuildWSclean( context.println 'Cleaning workspace non-hidden files: ' + context.WORKSPACE + '/*' context.sh(script: 'rm -rf ' + context.WORKSPACE + '/*') } catch (e) { - context.println "ERROR: Failed to clean workspace non-hidden files ${e}" + context.println "Warning: Failed to clean workspace non-hidden files ${e}" } // Clean remaining hidden files using cleanWs @@ -1652,14 +1652,14 @@ def postBuildWSclean( 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) { 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 "ERROR: Failed to clean workspace build output files ${e}" + context.println "Warning: Failed to clean workspace build output files ${e}" } } } else { @@ -2206,7 +2206,7 @@ def buildScriptsAssemble( try { context.cleanWs notFailBuild: true } catch (e) { - context.println "Failed to clean ${e}" + context.println "Warning: Failed to clean ${e}" } cleanWorkspace = false } @@ -2217,7 +2217,7 @@ def buildScriptsAssemble( context.println "Windows build cleaning" + context.WORKSPACE context.cleanWs notFailBuild: true } catch (e) { - context.println "ERROR: Failed to clean ${e}" + context.println "Warning: Failed to clean ${e}" } } }