将 Jenkins 与私有 BitBucket Git 存储库一起使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8208274/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 12:22:29  来源:igfitidea点击:

Using Jenkins with a private BitBucket Git repository

gitjenkinsbitbucket

提问by Ian Macalinao

When setting up a project in Jenkins that's hosted on bitbucket what would I put in the URL field?

在 Jenkins 中建立一个托管在 bitbucket 上的项目时,我会在 URL 字段中输入什么?

The repository is private.

存储库是私有的。

回答by ghickman

I'm not familiar with Jenkins but Bitbucket allows you to clone git repositories over https which can accept the password as part of the url, like so:

我不熟悉 Jenkins,但 Bitbucket 允许您通过 https 克隆 git 存储库,它可以接受密码作为 url 的一部分,如下所示:

https://<user>:<pass>@bitbucket.org/<user>/<project>.git

回答by Steven Craft

For this purpose I switched over to using the SSH protocol to talk to BitBucket. By doing this I was able to set up a private/public key pair, with the private key on my Jenkins build machine, and the public key added to my account on BitBucket. SSH can then be set up to authenticate based on this key pair.

为此,我改用 SSH 协议与 BitBucket 对话。通过这样做,我能够设置一个私钥/公钥对,在我的 Jenkins 构建机器上使用私钥,并将公钥添加到我在 BitBucket 上的帐户中。然后可以将 SSH 设置为基于此密钥对进行身份验证。

A word of warning, if your Jenkins machine is windows based, I'd avoid using plink/TortoisePLink as the SSH agent, and instead use OpenSSH from Cygwin as it is a lotfaster when cloning/updating large repositories. It was a little tricky to set this up at first, but would probably warrant a separate Stack Overflow question if required.

一个警告,如果你的 Jenkins 机器是基于 Windows 的,我会避免使用 plink/TortoisePLink 作为 SSH 代理,而是使用 Cygwin 的 OpenSSH,因为它在克隆/更新大型存储库时快得多。起初设置这个有点棘手,但如果需要,可能需要一个单独的堆栈溢出问题。

回答by Abhishek K

Please make sure GIT is installed and path is configured in Jenkins. To configure path have a look at the link Jenkins could not run git

请确保已安装 GIT 并在 Jenkins 中配置了路径。要配置路径,请查看链接Jenkins 无法运行 git

I am able to connect private repository using credentials in Jenkins. To connect using ssh please follow the youtube link Private repositories, GitHub & BitBucket

我能够使用 Jenkins 中的凭据连接私有存储库。要使用 ssh 进行连接,请点击 youtube 链接Private repositories, GitHub & BitBucket