Home > database >  How to deal with "Command "git clean -ffdx" returned status code 1" in Jenkins?
How to deal with "Command "git clean -ffdx" returned status code 1" in Jenkins?

Time:11-09

This happened to me and whilst I solved the problem using fragments of information I found here, I didn't find a simple clear answer - so here's the problem stated and answered.

I have a Jenkins CI job that is failing:

Command "git clean -ffdx" returned status code 1:

In my case because of difficulties removing Go packages:

 stdout: 

 stderr: warning: failed to remove go/pkg/mod/github.com/jfrog/build-info- 
 [email protected]/build/testdata/npm/_cacache/content-v2/sha512/32/d8: Permission denied

 warning: failed to remove go/pkg/mod/github.com/jfrog/build-info- 
 [email protected]/build/testdata/npm/_cacache/content-v2/sha512/75/67: Permission denied

How can I fix this?

CodePudding user response:

The answer is to use cleanWS() - but I found it only worked if I put it at the top of the pipeline. That means you have to specify skipDefaultCheckout(true) as one of your pipeline options.

I am running Windows and Linux pipelines in parallel.

In Windows I did this:

  parallel {
            stage("Windows") {
                agent {
                    node {
                        label "windows"
                    }
                }
                stages {
                    stage ("Windows test") {
                        steps {
                            cleanWs()
                            checkout scm
                            script {
                                runTestsOnWindows()
                            }
                        }
                    }
                }
            }

And in linux I created this (before anything else runs):

                   stage('Checkout scm') {
                        steps {
                            cleanWs()
                            checkout scm
                        }
                    }
  • Related