Hudson/Jenkins — how to access a private git repository on BitBucket.com

六月ゝ 毕业季﹏ 提交于 2019-12-06 06:01:06

问题


This question is long and multifaceted, so I'll start with a brief overview, and then show in detail everything I've tried and my questions as to why they don't work and what I'm doing wrong.

Overview

I'm trying to setup a Build Job on Hudson for source code on a private repository on BitBucket. There are a lot of similar questions on Stack Overflow, but for various reasons none of them address my needs.

I would like to access it using https instead of ssh, but there seems no way forward accessing it in Hudson with https, and everyone on the web seems sold on ssh. So I have tried to make it work with ssh, but in vain.

So, my central question is:
How can I access a private BitBucket repository in Hudson?

Notes

  • I realize Jenkins is better, but I'm working with an established Hudson Server. Please, no advice about switching to Jenkins.
    I included Jenkins in the title and as a tag because more likely than not any solution will be applicable to both.
  • Due to running into several dead-ends, I also ask a couple of "sub-questions" that elaborate on the core question above -- extra gratitude if you can enlighten me on them.

The Problem

I use the Git plugin for Hudson, and configure it as follows:

Since this is a private repository, it needs authentication somehow. So of course, the build failed. Here are the relevant parts of the stack trace:

ERROR: Error cloning remote repo 'origin' 
hudson.plugins.git.GitException:
Could not clone https://TJamesBoone@bitbucket.org/OtherUser/projectname.git
Caused by: hudson.plugins.git.GitException:
org.eclipse.jgit.api.errors.TransportException:
https://TJamesBoone@bitbucket.org/OtherUser/projectname.git: not authorized

Question: Why does the Git Plugin for Hudson not have a place in the project configuration for authentication for private repositories? After all, the SVN plugin can deal with authentication. Is there a good reason?

Things I Tried

I reconfigured the project to use the ssh url instead of the https url:

I then created a ssh key using this tutorial from Atlassian. I then added the ssh key to the project on BitBucket.

I tried building again, and got this stack trace (relevant parts):

ERROR: Error cloning remote repo 'origin' 
hudson.plugins.git.GitException:
Could not clone git@bitbucket.org:OtherUser/projectname.git
Caused by: hudson.plugins.git.GitException:
org.eclipse.jgit.api.errors.TransportException:
git@bitbucket.org:OtherUser/projectname.git:
UnknownHostKey: bitbucket.org. RSA key fingerprint is
97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40

I then figured I should try to configure Hudson with the two ssh plugins that were available, the Publish Over SSH plugin and the SSH plugin (which I learned about here).

But I can't figure out how to use them. First, I assume I don't need the Publish Over SSH plugin, because I'm not trying to publish, I'm just trying to pull. Secondly, the SSH plugin won't work for me. I've tried doing this:

But the problem here is that it can't connect. Furthermore, it wants a port number, and if I enter in nothing, 22 is used as a default. I have no idea what to do with it.

Question: Do I even need to configure an SSH site in order to successfully put from this private BitBucket repository?

Summary

How can I access a private BitBucket repository in Hudson?

In my Hudson build, I need to be able to pull from this private BitBucket repository. I can't seem to make it work with ssh, and I don't even know if using https is possible as there's no place for me to put in a password. If someone can help me either way, I'll be happy.


回答1:


For HTTPS connection, you should define ALSO your password within the HTTPS query like :

https://TJamesBoone:**PASSWORD**@bitbucket.org/OtherUser/projectname.git

For SSH connection, as said, you should see that DOC : https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git Don't forget to setup an EMPTY passphrase as jenkins does not support it. Don't forget to login first with jenkins user to git using ssh git@bitbucket.org

I can't provide more info your SSH case as I'm not running it on windows.

If that is not working, please tell us if : * jenkins is runned as a service * if not, what is the webserver used to run jenkins



来源:https://stackoverflow.com/questions/19550590/hudson-jenkins-how-to-access-a-private-git-repository-on-bitbucket-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!