The simplest way for Jenkins to get an interactive shell is to simply perform an interactive login, just like you do when you type "ssh slavehost". I.e. to omit the command to start the slave.
Other than that, Jenkins has little control over the way the sshd of the remote host starts the shell. After Jenkins has performed an interactive login, life is simple: the environment is the same as the interactive user environment. All that is left to do is to wait for a shell prompt to appear and then issue the command to run the slave. And handle any errors it might print. And carriage returns. And log out. So simple! At this point I bow my head in front of all this simplicity and go read the man page of the shell to find out where I have to place commands I want executed for all shells, not just interactive login shells. (.bashrc?) But, as they say, all progress depends on the unreasonable man. It would be great if you fixed this. This same problem has confused a lot of people and will no doubt continue to do so until someone makes Jenkins emulate an interactive user. -- Sami leojhartiv <[email protected]> kirjoitti 26.4.2012 kello 18.01: > I have a Linux machine that uses user account A. User account > A's .profile file loads all sorts of useful environment variables. > > I've tried to set up this machine as a Jenkins slave using the Launch > slave agents on Unix machines via SSH option: > > https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds#Distributedbuilds-Havemasterlaunchslaveagentviassh > > Everything connects fine and user A is connected, but I'm noticing > that none of user A's environment variables are being set. > > After some research, I've found that ssh, by default, does not > execute .profile unless you specify the -i (interactive) parameter: > > http://stackoverflow.com/questions/216202/why-does-an-ssh-remote-command-get-fewer-environment-variables-then-when-run-man > > So I'm trying to figure out how to either get Jenkins to specify -i > when connecting to the machine (looking at the source of > hudson.remoting.Launcher that doesn't seem to be an option) or some > other reusable way to get my user's environment set when > connecting. > > This seems to work correctly when using Java Web start to start my > slaves. > > Thanks!
