Configure Jenkins with Bitbucket

I seem to be stuck trying to connect Jenkins (EC2 AWS Ubuntu instance) with Bitbucket.

Whenever I try to create my project (I installed the git plugin on Jenkins), I get ...

Building in workspace /var/lib/jenkins/jobs/Google adwords/workspace Checkout:workspace / /var/lib/jenkins/jobs/Google adwords/workspace - hudson.remoting.LocalChannel@2c473996 Using strategy: Default Cloning the remote Git repository Cloning repository origin ERROR: Error cloning remote repo 'origin' : Could not clone git@bitbucket.org :DAVID99WORLD/assessme.git hudson.plugins.git.GitException: Could not clone git@bitbucket.org :DAVID99WORLD/assessme.git at hudson.plugins.git.GitAPI.clone(GitAPI.java:268) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1122) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064) at hudson.FilePath.act(FilePath.java:842) at hudson.FilePath.act(FilePath.java:824) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1064) at hudson.model.AbstractProject.checkout(AbstractProject.java:1256) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494) at hudson.model.Run.execute(Run.java:1502) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:236) Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git@bitbucket.org :DAVID99WORLD/assessme.git /var/lib/jenkins/jobs/Google adwords/workspace" returned status code 128: stdout: Cloning into '/var/lib/jenkins/jobs/Google adwords/workspace'... stderr: Host key verification failed. fatal: The remote end hung up unexpectedly 

Great - it looks like he is trying to go through ssh, but cannot find the keys. So I'm trying to generate keys, under ~/.ssh I have authorized_keys and known_hosts , but according to the documentation here ...

https://confluence.atlassian.com/display/BITBUCKET/How+to+install+a+public+key+on+your+bitbucket+account

I should have a file under ~ / .ssh called id_rsa

I follow the documentation ...

https://confluence.atlassian.com/display/BITBUCKET/Using+the+SSH+protocol+with+bitbucket

But it looks almost half finished, or I skip a bit where the key falls into the correct file.

Firstly - my guess is correct, is this an ssh problem? Secondly, if so, does anyone know how to get the keys to match so that Jenkins can do the attraction and build?

EDIT: I assumed this was an ssh problem since the Jenkins Build using git issue with the deployment key was related, but I use bitbucket, not github.

+3
java git bitbucket jenkins
source share
2 answers

You need to generate a key file to upload to your BitBucket account. From the user who runs Jenkins, follow these steps:

 ssh-keygen -t rsa 

Take the default location for the key file and leave the field phrase empty. Then you upload the file ~ / .ssh / id_rsa.pub for upload to BitBucket.

+6
source share

I read this post because I had the same problem and found something useful right now.

MY CONFIGURATION I have a subordinate building server (Win7-64 machine), where I installed the standard Git (during the installation I chose the third option: “Launch Git and enable Unix tools from the command line of the window”.) Jenkins is configured for Java Web Start.

I noticed that if I ran a command from the Git shell

ssh -vT git @ bitbucket.org

I can authenticate with the server receiving the message

You can use Git or hg to connect to Bitbucket. Shell access is disabled.

BUT, if I execute the same command from cmd, I get

Permission denied (publication)

I'm not sure, but I think that the Git plugin runs commands from a window shell, and not with a Git shell (as I expected), so this may determine the authentication problem in the assembly.

In the Git Plugin Documentation, there is a small section called "Some windows fun" offering to copy the user's .ssh folder to the Git section (in my case C: \ Program Files (x86) \ Git).

After that, I ran ssh -vT git @ bitbucket.org from the Windows shell and it worked (if it doesn’t work, try restarting the shell or the whole machine). Then I started the build with Jenkins and finally worked.

Hope this helps.

Good luck.

+1
source share

All Articles