Launch slave agents on Unix machines via SSH - Missing Environment

4,499 views
Skip to first unread message

leojhartiv

unread,
Apr 26, 2012, 11:01:38 AM4/26/12
to Jenkins Users
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!

Sami Tikka

unread,
Apr 28, 2012, 7:06:43 PM4/28/12
to jenkins...@googlegroups.com
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

Kamal Ahmed

unread,
Apr 29, 2012, 11:14:16 AM4/29/12
to jenkins...@googlegroups.com
Hi,
I have installed graphviz on the Jenkins host as well as on the slave, but the dependency graph doe snot get displayed. Instead just one button is showing with the Project name
and when i click on "Graph in graphviz format" link, then :

digraph {
node [shape=box, style=rounded];
subgraph clusterdepgraph {
"Axxelerate-dev" [href="http://10.0.11.214:8080/job/Axxelerate-dev/"];
color=white;
}
}

is displayed

Any idea how i can get the dependency graph
Thanks,
-Kamal.

Kamal Ahmed

unread,
Apr 30, 2012, 11:51:02 AM4/30/12
to jenkins...@googlegroups.com
resending in case this one slipped....
Did anyone experience / resolved this ?


From: Kamal Ahmed <kamal22...@yahoo.com>
To: "jenkins...@googlegroups.com" <jenkins...@googlegroups.com>
Sent: Sunday, April 29, 2012 11:14 AM
Subject: Dependency Graph - graphviz not displaying graph

Sami Tikka

unread,
May 1, 2012, 5:10:20 PM5/1/12
to jenkins...@googlegroups.com
2012/4/29 Sami Tikka <sjt...@gmail.com>:
> 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?)

Now that I actually looked into it instead of trying to look smart, I
discovered bash actually has no place from where it executes commands
for non-interactive, non-login shell. Sorry.

I think currently your best option is to add the environment variables
you need to the slave configuration, which allows you to define
environment variables for the slave.

Another option would be to change the login shell for the account on
the slave host which runs the slave. E.g. zsh has an initialization
file, .zshenv, which is executed for all non-login, non-interactive
shells too.

Hope this helps,

-- Sami
Reply all
Reply to author
Forward
0 new messages