Search code examples
gitjenkinspermissions

Jenkins, git clean permission denied error?


Looking for some help with this. Tried to find solutions from similar problems but have found nothing that works.

My pipeline executes fine the first time, although upon a second build, I retrieve this error, "git clean -ffdx" returned status code 1 , specifically...

using credential github

 > git rev-parse --is-inside-work-tree # timeout=10

Fetching changes from the remote Git repository

 > git config remote.origin.url https://github.com/XXXXX/XXXXXX.git # timeout=10

Cleaning workspace

 > git rev-parse --verify HEAD # timeout=10

Resetting working tree

 > git reset --hard # timeout=10

 > git clean -ffdx # timeout=10

ERROR: Error fetching remote repo 'origin'

hudson.plugins.git.GitException: Failed to fetch from https://github.com/XXXXXX/XXXXXX.git

    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:915)

    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1141)

    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1177)

    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)

    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)

    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)

    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)

    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

    at java.util.concurrent.FutureTask.run(FutureTask.java:266)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

    at java.lang.Thread.run(Thread.java:748)

Caused by: hudson.plugins.git.GitException: Command "git clean -ffdx" returned status code 1:

stdout: 

stderr: warning: failed to remove 1/src/build/table_select_window/PYZ-00.toc: Permission denied

warning: failed to remove 1/src/build/table_select_window/xref-table_select_window.html: Permission denied

warning: failed to remove 1/src/build/table_select_window/EXE-00.toc: Permission denied

warning: failed to remove 1/src/build/table_select_window/Analysis-00.toc: Permission denied

warning: failed to remove 1/src/build/table_select_window/PKG-00.pkg: Permission denied

warning: failed to remove 1/src/build/table_select_window/PKG-00.toc: Permission denied

warning: failed to remove 1/src/build/table_select_window/PYZ-00.pyz: Permission denied

warning: failed to remove 1/src/build/table_select_window/warn-table_select_window.txt: Permission denied

warning: failed to remove 1/src/build/table_select_window/base_library.zip: Permission denied

warning: failed to remove 1/src/dist/table_select_window: Permission denied

warning: failed to remove 1/src/__pycache__/table_select_window.cpython-37.pyc: Permission denied



    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2437)

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2367)

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2363)

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1923)

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1935)

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clean(CliGitAPIImpl.java:1017)

    at hudson.plugins.git.extensions.impl.CleanBeforeCheckout.decorateFetchCommand(CleanBeforeCheckout.java:45)

    at hudson.plugins.git.extensions.GitSCMExtension.decorateFetchCommand(GitSCMExtension.java:288)

    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:911)

    ... 11 more

Error fetching remote repo 'origin'

I have tried restarting my machine, as well as enabling 'clean before checkout' in Jenkins and have had no luck. I am running windows 10 and jenkins through docker. Any help is appreciated.

Thanks.


Solution

  • To prevent this from happening in future builds, you can add the following to your jenkinsfile (to run after all stages).

    post 
    {
        always 
        {
            yumCleanUp()
            cleanWs()
        }
    }