diff --git a/Jenkinsfile b/Jenkinsfile index e8c3be8..5e47c8f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 + ''' } } }