How to clone a BitBucket repository with Jenkins

17,339

For Jenkins 1.5 or greater( till 1.6)

The error you are getting because in the global configuration of Jenkins, the git path is not correct/or not inserted.

That's why Jenkins is unable to run the git command.

Please go to Manage Jenkins-> Configure System Settings. Check for git section and add correct path.

enter image description here Its already seems that you have removed the Git Clone from the URL provided by Bitbucket.

Update:

For Jenkins 2.0 or above

You can find this setting under Global tool configuration.

Share:
17,339

Related videos on Youtube

Varun
Author by

Varun

Updated on September 16, 2022

Comments

  • Varun
    Varun over 1 year

    I am using RedHat Linux

    1. I have created a repository in BitBucket say Demo and I have some HTML code into that.
    2. I have installed Jenkins on my system.

    What I am trying to do is clone the BitBucket repository with Jenkins so that I will be able to build the project.

    Steps what I am following is

    1. Creating a new Job In Jenkins.
    2. Giving a description of the project
    3. In the Source Code Management tab selecting git and Jenkins ask for repository URL, and I am giving this URL. enter image description here

    but Jenkins throwing an error saying:

    Failed to connect to repository : Error performing command: git ls-remote -h git clone https://[email protected]/UserName/java-script.git HEAD

    I spent around 3 days and could not configure this instead learned a lot about Jenkins. I have also tried the BitBucket plug-in for Jenkins that also was not working.

  • Varun
    Varun almost 9 years
    When I am giving the whole URL git clone [email protected]/DrunkenCooder/java-script.git , it throws this "Failed to connect to repository : Error performing command: git ls-remote -h git clone [email protected]/DrunkenCooder/java-script.git HEAD "
  • Varun
    Varun almost 9 years
    When I am giving only URL [email protected]/DrunkenCooder/java-script.git , it throws this " Failed to connect to repository : Error performing command: git ls-remote -h [email protected]/DrunkenCooder/java-script.git HEAD"
  • Bruno Lavit
    Bruno Lavit almost 9 years
    On your Jenkins server, are you able to run the git clone http//... command?
  • Varun
    Varun almost 9 years
    correct path. in the sense the Bitbucket path which I have shown in the above scree
  • Abhijeet Kamble
    Abhijeet Kamble almost 9 years
    no not the bitbucket path. i am talking about the path where git is installed on your system. for ex. my machine is linux(centos 6.5) and in my case git is installed at /usr/local/bin/git. or if its windows it might be C:\Program Files\Git\bin\git.exe
  • Abhijeet Kamble
    Abhijeet Kamble almost 9 years
    the bitbucket path is correct. [email protected]/DrunkenCooder/java-script.git
  • Varun
    Varun almost 9 years
    Sorry bro i have not installed git in my system. I'll just do that. but, why do we need git since we are pulling the code from Bitbucket ?
  • Abhijeet Kamble
    Abhijeet Kamble almost 9 years
    Jenkins doesn't comes with GIT,So we have to install GIT and have to tell Jenkins about GIT path so that Jenkins can run GIT commands at backend. Hope this has answered your question.
  • Varun
    Varun almost 9 years
    After installing git and after giving the path I am getting this error
  • Varun
    Varun almost 9 years
    Could not init /tmp/hudson4551896643487321839tmp
  • Varun
    Varun almost 9 years
    as u have mention I have specified the git executable path /usr/bin/git . now I have getting this error "Failed to connect to repository : Command "/usr/bin/git config --local credential.helper store --file=/tmp/git3516666924035828487.credentials" returned status code 129: stdout: stderr: error: unknown option `local' usage: git config [options] Config file location --global use global config file --system use system config file -f, --file <FILE> use given config file
  • vaskort
    vaskort over 7 years
    instead of Configure System Settings in Jenkins 2.27 it's called Global Tool Configuration
  • Abhijeet Kamble
    Abhijeet Kamble over 7 years
    @BillK Yes you are right, Now from Jenkins 2 its defined under Global Tool Configuration.