In Jenkins in K8S pod I'm using checkout in my scripted pipeline (The job is running in root permission) -
checkout([$class : 'GitSCM', branches: [[name: branch]], doGenerateSubmoduleConfigurations: false,
extensions : [[$class: 'CheckoutOption', timeout: 120]], submoduleCfg: [],
userRemoteConfigs: [[credentialsId: gitCredentials, url: url]],
clean: false])
But I'm getting this error -
ERROR: Failed to clean the workspace
15:10:05 jenkins.util.io.CompositeIOException: Unable to delete '/home/jenkins/agent/workspace/
After verifying the filesystem permissions, I've figured out I'm using root permissions in the entire job (If I do sh 'whoami' I see root), but I think the checkout itself is using 'Jenkins' permissions and therefore it cannot remove files that has root permissions
Can I -
Use different user permissions? like Jenkins for example but just for the checkout? I don't want to have Jenkins permissions to the entire job.
Can I skip cleanup? If the issue with the cleanup, I can avoid it, how can I do checkout of a branch without cleanup?