简体   繁体   中英

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

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:

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:

Git配置

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

Why does the Git Plugin for Hudson not have a place in the project configuration for authentication for private repositories? 为什么哈德逊的Git插件在项目配置中没有用于私有存储库身份验证的位置? 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:

使用SSH URL的Git Config

I then created a ssh key using from Atlassian. 创建了一个ssh密钥。 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 ). 学到了)。

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:

SSH站点配置

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.

Do I even need to configure an SSH site in order to successfully put from this private BitBucket repository? 为了成功从此专用BitBucket存储库中放入,我是否甚至需要配置SSH站点?

Summary

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM