Fix Jenkins workspace cleanup with chmod before rm
qt-migration-copilot-demo/pipeline/pr-main There was a failure building this commit

- Replace cleanWs with shell commands that fix permissions before deletion
- Handle build/, build-coverage/, and coverage/ directories
- Use chmod -R u+w to make files writable before rm -rf
- Addresses 'Operation not permitted' errors on Jenkins host

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Entire-Checkpoint: 9acfd6cc578c
This commit is contained in:
torstenandCopilot committed 2026-10-22 18:20:35 +02:00
1 parent 50073e010f
commit ba8479fa8d
1 file changed
+36 -2
Vendored
+36 -2
View File
@@ -27,7 +27,24 @@ pipeline {
steps {
script {
echo "Cleaning workspace to avoid corruption issues..."
cleanWs deleteDirs: true, disableDeferredWipeout: true
// Use shell command with chmod to handle permission issues
sh '''
if [ -d "${WORKSPACE}/${BUILD_DIR}" ]; then
echo "Removing build directory with permission fix..."
chmod -R u+w "${WORKSPACE}/${BUILD_DIR}" 2>/dev/null || true
rm -rf "${WORKSPACE}/${BUILD_DIR}"
fi
if [ -d "${WORKSPACE}/${COVERAGE_BUILD_DIR}" ]; then
echo "Removing coverage build directory..."
chmod -R u+w "${WORKSPACE}/${COVERAGE_BUILD_DIR}" 2>/dev/null || true
rm -rf "${WORKSPACE}/${COVERAGE_BUILD_DIR}"
fi
if [ -d "${WORKSPACE}/coverage" ]; then
echo "Removing coverage output directory..."
chmod -R u+w "${WORKSPACE}/coverage" 2>/dev/null || true
rm -rf "${WORKSPACE}/coverage"
fi
'''
}
}
}
@@ -112,7 +129,24 @@ pipeline {
always {
script {
if (getContext(hudson.FilePath)) {
cleanWs deleteDirs: true, disableDeferredWipeout: true
// Use shell command with chmod to handle permission issues
sh '''
if [ -d "${WORKSPACE}/${BUILD_DIR}" ]; then
echo "Final cleanup: Removing build directory..."
chmod -R u+w "${WORKSPACE}/${BUILD_DIR}" 2>/dev/null || true
rm -rf "${WORKSPACE}/${BUILD_DIR}"
fi
if [ -d "${WORKSPACE}/${COVERAGE_BUILD_DIR}" ]; then
echo "Final cleanup: Removing coverage build directory..."
chmod -R u+w "${WORKSPACE}/${COVERAGE_BUILD_DIR}" 2>/dev/null || true
rm -rf "${WORKSPACE}/${COVERAGE_BUILD_DIR}"
fi
if [ -d "${WORKSPACE}/coverage" ]; then
echo "Final cleanup: Removing coverage output..."
chmod -R u+w "${WORKSPACE}/coverage" 2>/dev/null || true
rm -rf "${WORKSPACE}/coverage"
fi
'''
}
}
}