Skip to content

Commit 5bb8310

Browse files
Windows docker build ensure cleanWorkspace cleans build tmp workspace (#1167)
* Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard <[email protected]> * Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard <[email protected]> * Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard <[email protected]> * Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard <[email protected]> * Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard <[email protected]> * Update pipelines/build/common/openjdk_build_pipeline.groovy Co-authored-by: Stewart X Addison <[email protected]> * Update pipelines/build/common/openjdk_build_pipeline.groovy Co-authored-by: Stewart X Addison <[email protected]> * Update pipelines/build/common/openjdk_build_pipeline.groovy Co-authored-by: Stewart X Addison <[email protected]> * Windows docker build ensure cleanWorkspace cleans build tmp workspace Signed-off-by: Andrew Leonard <[email protected]> --------- Signed-off-by: Andrew Leonard <[email protected]> Co-authored-by: Stewart X Addison <[email protected]>
1 parent 207bcc8 commit 5bb8310

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

pipelines/build/common/openjdk_build_pipeline.groovy

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,19 +1640,27 @@ def postBuildWSclean(
16401640
// Issue: https://issues.jenkins.io/browse/JENKINS-64779
16411641
if (context.WORKSPACE != null && !context.WORKSPACE.isEmpty()) {
16421642
if (cleanWorkspaceAfter) {
1643-
context.println 'Cleaning workspace non-hidden files: ' + context.WORKSPACE + '/*'
1644-
context.sh(script: 'rm -rf ' + context.WORKSPACE + '/*')
1643+
try {
1644+
context.println 'Cleaning workspace non-hidden files: ' + context.WORKSPACE + '/*'
1645+
context.sh(script: 'rm -rf ' + context.WORKSPACE + '/*')
1646+
} catch (e) {
1647+
context.println "Warning: Failed to clean workspace non-hidden files ${e}"
1648+
}
16451649

16461650
// Clean remaining hidden files using cleanWs
16471651
try {
16481652
context.println 'Cleaning workspace hidden files using cleanWs: ' + context.WORKSPACE
16491653
context.cleanWs notFailBuild: true, disableDeferredWipeout: true, deleteDirs: true
16501654
} catch (e) {
1651-
context.println "Failed to clean ${e}"
1655+
context.println "Warning: Failed to clean ${e}"
16521656
}
16531657
} else if (cleanWorkspaceBuildOutputAfter) {
1654-
context.println 'Cleaning workspace build output files under ' + context.WORKSPACE
1655-
batOrSh('rm -rf ' + context.WORKSPACE + '/workspace/build/src/build ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput')
1658+
try {
1659+
context.println 'Cleaning workspace build output files under ' + context.WORKSPACE
1660+
batOrSh('rm -rf ' + context.WORKSPACE + '/workspace/build/src/build ' + context.WORKSPACE + '/workspace/target ' + context.WORKSPACE + '/workspace/build/devkit ' + context.WORKSPACE + '/workspace/build/straceOutput')
1661+
} catch (e) {
1662+
context.println "Warning: Failed to clean workspace build output files ${e}"
1663+
}
16561664
}
16571665
} else {
16581666
context.println 'Warning: Unable to clean workspace as context.WORKSPACE is null/empty'
@@ -1687,6 +1695,7 @@ def buildScriptsAssemble(
16871695
batOrSh "rm -rf ${base_path}/jdk/modules/jdk.jpackage/jdk/jpackage/internal/resources/*"
16881696
}
16891697
context.stage('assemble') {
1698+
try {
16901699
// This would ideally not be required but it's due to lack of UID mapping in windows containers
16911700
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE) {
16921701
context.bat('chmod -R a+rwX ' + '/cygdrive/c/workspace/openjdk-build/workspace/build/src/build/*')
@@ -1756,7 +1765,9 @@ def buildScriptsAssemble(
17561765
}
17571766
throw new Exception("[ERROR] Build archive timeout (${buildTimeouts.BUILD_ARCHIVE_TIMEOUT} HOURS) has been reached. Exiting...")
17581767
}
1768+
} finally {
17591769
postBuildWSclean(cleanWorkspaceAfter, cleanWorkspaceBuildOutputAfter)
1770+
}
17601771
} // context.stage('assemble')
17611772
} // End of buildScriptsAssemble() 1643-1765
17621773

@@ -2195,10 +2206,21 @@ def buildScriptsAssemble(
21952206
try {
21962207
context.cleanWs notFailBuild: true
21972208
} catch (e) {
2198-
context.println "Failed to clean ${e}"
2209+
context.println "Warning: Failed to clean ${e}"
21992210
}
22002211
cleanWorkspace = false
22012212
}
2213+
// For Windows build also clean alternative(shorter path length) workspace
2214+
if ( buildConfig.TARGET_OS == 'windows' ) {
2215+
context.ws(workspace) {
2216+
try {
2217+
context.println "Windows build cleaning" + context.WORKSPACE
2218+
context.cleanWs notFailBuild: true
2219+
} catch (e) {
2220+
context.println "Warning: Failed to clean ${e}"
2221+
}
2222+
}
2223+
}
22022224
}
22032225
} catch (FlowInterruptedException e) {
22042226
throw new Exception("[ERROR] Controller clean workspace timeout (${buildTimeouts.CONTROLLER_CLEAN_TIMEOUT} HOURS) has been reached. Exiting...")

pipelines/build/prTester/pr_test_pipeline.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class PullRequestTestPipeline implements Serializable {
163163
context.booleanParam(name: 'enableInstallers', value: false), // never need this enabled in pr-test
164164
context.booleanParam(name: 'useAdoptBashScripts', value: false), // should not use defaultsJson but adoptDefaultsJson
165165
context.booleanParam(name: 'keepReleaseLogs', value: false), // never need this enabled in pr-tester
166+
context.booleanParam(name: 'cleanWorkspace', value: true), // always clean prtester workspace before the build
166167
context.booleanParam(name: 'cleanWorkspaceAfterBuild', value: true) // always clean prtester workspace after the build
167168
]
168169
} catch (err) {

0 commit comments

Comments
 (0)