unable to configure bamboo to find ssh (tortoiseplink)
Asked by Ozan Yigit:

This is a previously reported issue, with no apparent solution. typical windows mercurial setup, with tortoisehg and putty.  
mercurial settings correct, and will work via command line, eg. hg clone <ssh://hg@mygate/etc> works as expected, and  
has worked on all clients we have configured for well over a year.

this particular instance is a bamboo build agent. the exception is:

java.lang.RuntimeException : com.atlassian.bamboo.plugins.hg.HgCommandException: command \[C:\\Program Files\\TortoiseHg\\hg.exe, pull, --rev, 4f1078e129ffe12bd25979c49f957972c55b3ed7, --config, ui.ssh=ssh -o StrictHostKeyChecking=no -o BatchMode=yes, ssh://hg@mygate/foo\] failed. Working directory was \`C:\\Documents and Settings\\oyigit\\bamboo-agent-home\\xml-data\\build-dir\\_hg-repositories-cache\\b7b75c29066a14265a4be83a36e96f946f326e2b'. stderr: abort: no suitable response from remote hg! stdout: remote: 'ssh' is not recognized as an internal or external command,remote: operable program or batch file.)

note how the outgoing command re-maps ssh as ssh, instead of using mercurial.ini setup, which specifically sets ssh as tortoiseplink, eg.

ssh= tortoiseplink.exe -ssh -i "C:\\blah\\blah'privkey.ppk"

so what gives? i cannot see any settings that would have my build server to issue the right command to its windows agent, where ssh is tortoiseplink.

yes, I can install some other ssh command, but i need to understand whether this is a bamboo bug i have to work around, or some configuration i have overlooked.

i have already tried setting up a custom executable ssh with the proper path via agents conrol panel. doesn't work.


Answers:
author: Przemek Bruski
body: You need to set the Bamboo capability: system.hg.executable.ssh to the SSH executable you wish to use. Otherwise it defaults to "ssh -o StrictHostKeyChecking=no -o BatchMode=yes"

comments: author: Jean-Dominique GASCUEL
body: To do so, just use the SECOND executabe (SSH) proposed in the add-capability menu for Mercurial...


author: PiotrA
body: Which "autorization type" have you set up in your plan repository configuration?

I'm thinking that the last one, called "Default Mercurial credentials" could force Bamboo to use ssh configured in mercurial.ini... but I might be wrong - can't check it right now.

comments: author: Ozan Yigit
body: auth type is keyfile without passphrase. keyfile is supposed to come from the "bamboo" user on the agent, it is specified,  
registered etc. but with the --config ui.ssh=ssh line, the actual mercurial configuration that specifies the keyfile is bypassed.


author: ReneR
body: How are you running the agent? What user account? Is it running as a service? With the system account?

Mercurial expects to find your .ini or .hgrc file using the %USERPROFILE% environment variable. Since the Hg command is being spawned by Bamboo thru the agent (which is a Java process) you shouldn't assume that the behaviour you'll see from that will be the same as when logged in with your own user on the Desktop.

Setup a dummy Job with a script task in it and run something like: "hg -v showconfig"

Or make sure the account you're using to run the agent has a USERPROFILE environment variable set. Or you can pass that as an env var in the Job where you need it.

comments: author: Ozan Yigit
body: thanks for the response. agent was run in two different ways: once as an nt service, and the other as a "bamboo" administrative user, at console. hg -v showconfig indicates tortoisehg configuration is correct, ui.ssh is properly defined as tortoisehgplink, with pointer to the private key. the bottom line comes to --config line, which defines ui.ssh as ssh. i have no idea what possible configuration could change this: it bypasses mercurial.ini configuration.


author: ReneR
body: hg help config  
Can tell you where Mercurial expects to find initialization files.


author: Jay Barra
body: Do you have any saved sessions in PuTTY?

comments: author: Ozan Yigit
body: good question, but no, everything is fresh, no saved sessions. host keys initialized.  
i know of a really ugly fix: cp tortoiseplink.exe ssh.exe  
but i'd rather have a clean configuration for this.


Tags: client

command

ssh

windows