Varun
Varun

Reputation: 4452

How to clone a BitBucket repository with Jenkins

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.

Upvotes: 7

Views: 22799

Answers (3)

Anu Raj
Anu Raj

Reputation: 1

This is because private key is not establishing to GIT through Jenkins.

So create credentials:

  1. go to Jenkin Configure==>Source Code Management==>Add==>Jenkins;
  2. select Domain as global;
  3. select Kind 'SSH username with password';
  4. Copy the user name from id_rsa.pub file and paste it in username field;
  5. Copy the private key from id_rsa file and paste it in 'Private Key==> Enter directly'

It should work, try it.

Upvotes: -1

Abhijeet Kamble
Abhijeet Kamble

Reputation: 3201

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.

Upvotes: 8

Bruno Lavit
Bruno Lavit

Reputation: 10382

Remove the "git clone" keywords and it should work :)

Jenkins only need the http URL:

https://[email protected]/UserName/java-script.git

Upvotes: 0

Related Questions