0

While trying to run a jenkins job the job breaks with error:

git clone https://XXXX%@github.com/XXX/XXX
fatal: destination path 'ns-test' already exists and is not an empty directory.

It seems that each run shares the same directory.

Is this correct?

I was wondering the jenkins job was running in isolation..

My script is:

pipeline {
agent { 
   docker { 
    image 'python:3.5.1' 
    args '-v=/etc/passwd:/etc/passwd'
    } 
}
stages {
    stage('checkout') {
        steps {
            sh 'git clone https://XXXX:XXXX%@github.com/XXXX/XXXX.git'
        }
    }
    stage('build') {
        steps {
            sh 'ls && pip install -r requirements.txt '
        }
    }
}
Matt
  • 12,848
  • 2
  • 31
  • 53

1 Answers1

0

This error comes up when you try to clone a repository in a folder which still contains .git folder.
Git clone copied the files down from github and placed them into a folder. If you try to do it again it will not let you because it can't clone into a folder that already has files into it.
So solutions could be :

  1. Either remove the folder before doing a clone. sh 'rm -rf .git'
  2. Use git plugin : More info : In Jenkins, how to checkout a project into a specific directory (using GIT)
Altaf
  • 2,838
  • 1
  • 16
  • 8