Skip to content

Commit

Permalink
Windows docker build ensure cleanWorkspace cleans build tmp workspace (
Browse files Browse the repository at this point in the history
…#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]>
  • Loading branch information
andrew-m-leonard and sxa authored Dec 18, 2024
1 parent 207bcc8 commit 5bb8310
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
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

0 comments on commit 5bb8310

Please sign in to comment.