How to setup Authorization Hudson /Jenkins to clone your mercurial repository

David picture David · Apr 2, 2011 · Viewed 18.1k times · Source

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 .

Answer

David picture David · Apr 3, 2011

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.