Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows docker build ensure cleanWorkspace cleans build tmp workspace #1167

Merged
merged 9 commits into from
Dec 18, 2024
Merged
34 changes: 28 additions & 6 deletions pipelines/build/common/openjdk_build_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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/*')
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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...")
Expand Down
1 change: 1 addition & 0 deletions pipelines/build/prTester/pr_test_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading