Fix Jenkins workspace cleanup with chmod before rm
- 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 Signed-off-by: twi-devel <torsten.wierschin@life-maps.com>
This commit is contained in:
1 file changed
+36
-2
Vendored
+36
-2
@@ -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
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user