如何设置授权 Hudson /Jenkins 来克隆您的 Mercurial 存储库

发布于 2024-10-30 07:29:37 字数 2360 浏览 1 评论 0原文

安装并使用 Mercurial 后,我试图让 Hudson 克隆存储库,以便它可以构建我的项目。

目前以下任务有效。

  • 我可以同步到我的外部主机,并且代码显示在该主机上。

现在我正在尝试配置 hudson / jenkins 以访问我的主机上的代码。

但不幸的是,我遇到了一个错误:

Started by user anonymous
$ hg clone --rev default https://bitbucket.org/*/testproject "F:\Hudson\jobs\testproject\workspace"
abort: http authorization required
ERROR: Failed to clone https://bitbucket.org/*/testproject
[workspace] $ hg log --rev . --template {node}
java.io.IOException: Cannot run program "hg" (in directory "F:\Hudson\jobs\testproject\workspace"): CreateProcess error=267, The directory name is invalid
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:698)
    at hudson.Launcher$ProcStarter.start(Launcher.java:329)
    at hudson.Launcher$ProcStarter.join(Launcher.java:336)
    at hudson.plugins.mercurial.MercurialSCM.joinWithPossibleTimeout(MercurialSCM.java:298)
    at hudson.plugins.mercurial.HgExe.popen(HgExe.java:191)
    at hudson.plugins.mercurial.HgExe.tip(HgExe.java:171)
    at hudson.plugins.mercurial.MercurialSCM.calcRevisionsFromBuild(MercurialSCM.java:254)
    at hudson.scm.SCM._calcRevisionsFromBuild(SCM.java:304)
    at hudson.model.AbstractProject.calcPollingBaseline(AbstractProject.java:1186)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1175)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:523)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:418)
    at hudson.model.Run.run(Run.java:1362)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:145)
Caused by: java.io.IOException: CreateProcess error=267, The directory name is invalid
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
    ... 18 more
Finished: FAILURE

我需要执行哪些操作才能告诉 Hudson 使用用户名 x 和密码 y 来访问数据?

已编辑 =>找到了如何集成 ssh 。

After installing and playing around with mercurial , I am trying to get Hudson to clone the repository so it can build my project.

At the moment the following task works.

  • I Can sync to my external host and the code shows up on that host.

Now I am trying to configure hudson / jenkins to access the code on my host.

But unfortunately I am rolling on a error:

Started by user anonymous
$ hg clone --rev default https://bitbucket.org/*/testproject "F:\Hudson\jobs\testproject\workspace"
abort: http authorization required
ERROR: Failed to clone https://bitbucket.org/*/testproject
[workspace] $ hg log --rev . --template {node}
java.io.IOException: Cannot run program "hg" (in directory "F:\Hudson\jobs\testproject\workspace"): CreateProcess error=267, The directory name is invalid
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:698)
    at hudson.Launcher$ProcStarter.start(Launcher.java:329)
    at hudson.Launcher$ProcStarter.join(Launcher.java:336)
    at hudson.plugins.mercurial.MercurialSCM.joinWithPossibleTimeout(MercurialSCM.java:298)
    at hudson.plugins.mercurial.HgExe.popen(HgExe.java:191)
    at hudson.plugins.mercurial.HgExe.tip(HgExe.java:171)
    at hudson.plugins.mercurial.MercurialSCM.calcRevisionsFromBuild(MercurialSCM.java:254)
    at hudson.scm.SCM._calcRevisionsFromBuild(SCM.java:304)
    at hudson.model.AbstractProject.calcPollingBaseline(AbstractProject.java:1186)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1175)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:523)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:418)
    at hudson.model.Run.run(Run.java:1362)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:145)
Caused by: java.io.IOException: CreateProcess error=267, The directory name is invalid
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
    ... 18 more
Finished: FAILURE

What actions do i need to do to tell Hudson to use username x and password y to acces the data?

Edited => Found how to integrate ssh .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

不气馁 2024-11-06 07:29:37

使用 SSH 而不是 https

从 PuTTY 网站下载 putty.exe、puttygen.exe、pageant.exe 和 plink.exe。
启动 puttygen 并生成OPENSSH FORMAT(hudsons 格式)的密钥 (=> 如何使用 Svn + SSH )

单击保存私钥按钮并将 .PPK 文件保存在某处。
单击保存公钥按钮并保存。

转到您的网站并输入公共 ssh 密钥

运行 pageant.exe。选美图标(戴着帽子的计算机)将显示在状态托盘中。

右键单击选美图标并选择添加键。
选择您之前保存的 .PPK 文件并输入其密码。

以下内容(结尾部分是复制的)来自 Ted Naleid(谢谢!)博客女巫,可以在这里找到:将 hudson 连接到您的 ...

在 Hudson 中安装 Mercurial 插件

现在剩下要做的就是安装
Hudson 中的 Mercurial 插件。在一个
浏览器,转到
http://INSERT_YOUR_IP_HERE:8080
哈德森应该出现。

点击“管理 Hudson”并转至
“管理插件”。前往
“可用”选项卡,选中“Hudson
Mercurial 插件”并点击
“安装”按钮。 Hudson 会提示
你重新启动,然后就可以了
已安装。

之后,只需创建一个新作业并
你将有一个新的“mercurial”选项
在“源头控制管理”中
部分。选择它并输入 ssh
“存储库 URL”字段中的 URL。
然后将“默认”放入“分支”中
字段并设置其余的工作
构建/测试您的代码(练习
留给读者)。

这是第一个成功的构建!
First succefull build

结论:这是散布在互联网上的所有小博文的摘要。我希望这篇文章可以帮助您启动 Hudson 和 Mercurial。

Used SSH instead of https

Download putty.exe, puttygen.exe, pageant.exe, and plink.exe from the PuTTY website.
Start puttygen and generate a key in OPENSSH FORMAT (hudsons format) (=> How to use Svn + SSH )

Click the Save private key button and save the .PPK file somewhere.
Click the Save public key button and save it.

Go to your website and enter the public ssh-key

Run pageant.exe. The pageant icon (a computer wearing a hat) will show up in the status tray.

Right-click the pageant icon and choose Add Key.
Choose the .PPK file you saved earlier and type in its passphrase.

The following (end part is copied) from Ted Naleid (Thank you!) blog witch can be found here : Hooking up hudson to your ...

Install the Mercurial plugin in Hudson

All that’s left to do now is install
the Mercurial plugin in hudson. In a
browser, go to
http://INSERT_YOUR_IP_HERE:8080.
Hudson should come up.

Click on “Manage Hudson” and go to
“Manage Plugins”. Go to the
“Available” tab, check “Hudson
Mercurial plugin” and hit the
“Install” button. Hudson will prompt
you to restart, and then it’s
installed.

After that, just create a new job and
you’ll have a new “mercurial” option
in the “source control management”
section. Select that and put the ssh
URL in the “Repository URL” field.
Then put “default” in the “branch”
field and set up the rest of the job
to build/test your code (an exercise
left to the reader).

and here it is the first succesfull build !
First succefull build

Conclusion : This is a summary of all the small blogpost scattered arround the internet. I hope this post helps you in starting hudson and mercurial.

始终不够 2024-11-06 07:29:37

我认为问题与用户名和密码无关。您的堆栈跟踪告诉您路径F:\Hudson\jobs\testproject\workspace有问题。

无法运行程序 hg(在目录中)
“F:\Hudson\jobs\testproject\workspace”)

目录名称无效

无论如何,您可以在 URL 中指定用户名和密码,例如: http://user:[电子邮件受保护]

I think the problem is not related to username and password. Your stacktrace tells you there's something wrong with the path F:\Hudson\jobs\testproject\workspace.

Cannot run program hg (in directory
"F:\Hudson\jobs\testproject\workspace")

The directory name is invalid

Anyway, you can specify the username and password in the URL like: http://user:[email protected].

狼性发作 2024-11-06 07:29:37

为了使用 BitBucket 验证 Jenkins/Hudson Mercurial 插件,我也发现使用 SSH 协议而不是 HTTPS 很有用,特别是因为:

  1. 似乎没有办法使用 Mercurial Jenkins 插件将 HTTPS 凭证存储到 BitBucket ,但是通过 SSH,您可以安全可靠地存储您的凭据

  2. < p>使用 SSH,您可以将其配置为使用压缩,而 Mercurial 本身并不执行此操作。

这里提供了有关设置对 BitBucket 的 SSH 访问的良好说明: http://confluence.atlassian.com/display/BITBUCKET/Using+SSH+to+Access+your+Bitbucket+Repository

注意:

  • 如果您在 *nix 服务器上运行 Jenkins/Hudson ,您将希望以运行 Jenkins 进程的用户身份登录,并从该用户主目录执行这些操作,因此该用户将找到配置(例如,在我的 Jenkins 独立安装的 Debian 服务器上,创建了用户“jenkins”)并且主目录设置为“/var/lib/jenkins”[不是 /home/jenkins] - 我在其中执行了上面链接中提供的说明)。

  • 我发现在尝试让 Jenkins 调用之前确保 hg clone 命令在命令行中工作非常有帮助。

  • 重要提示:为了使其正常工作,我必须生成一个没有 ** 密码的密钥 **。

To authenticate the Jenkins/Hudson Mercurial plugin with BitBucket I too found it useful to use the SSH protocol instead of HTTPS particularly since:

  1. there doesn't seem to be a way to store your HTTPS credentials to BitBucket with the Mercurial Jenkins plugin, but with SSH you can safely and securely store your credentials

  2. with SSH you can configure it to use compression, which Mercurial doesn't do natively.

Good instructions for setting up SSH access to BitBucket are available here: http://confluence.atlassian.com/display/BITBUCKET/Using+SSH+to+Access+your+Bitbucket+Repository

Notes:

  • If you are running Jenkins/Hudson on a *nix server, you will want to login as the user running the Jenkins process and perform these operations from that users home directory, so the configurations will be found by that user (e.g. on my Debian server installation of Jenkins standalone, the user 'jenkins' is created and the home directory is set to '/var/lib/jenkins' [not /home/jenkins] - where I performed the instructions provided at the above link).

  • I found it very helpful to assure the hg clone command worked from the command line before attempting to have Jenkins call it.

  • IMPORTANT: In order to get this to work, I had to generate a key ** without ** a passphrase.

披肩女神 2024-11-06 07:29:37

您可以将以下行添加到 jenkins .hgrc 文件(通常为 /var/lib/jenkins/.hgrc)

[auth]
bitbucket.prefix = https://bitbucket.org/your_user/...
bitbucket.username = your_user
bitbucket.password = ******

请参阅 http://www.selenic.com/mercurial/hgrc.5.html#auth

You can add the following lines to jenkins .hgrc file (usually /var/lib/jenkins/.hgrc)

[auth]
bitbucket.prefix = https://bitbucket.org/your_user/...
bitbucket.username = your_user
bitbucket.password = ******

See http://www.selenic.com/mercurial/hgrc.5.html#auth

醉殇 2024-11-06 07:29:37

您可以在 Jenkins 的“Credentials”部分添加 scm 凭据:

在此处输入图像描述

同时更改作业配置以使用凭据:

在此处输入图像描述

You can add your scm credentials in the 'Credentials` section of Jenkins:

enter image description here

Also change the job configuration to use the credentials:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文