I have a script called test.sh
on a remote server. It prints an environment variable that has been set in the .profile
and looks like this:
#!/bin/ksh
echo "JAVA_HOME: $JAVA_HOME"
When I run the script manually I get the same result as with an echo command.
my_user@remote_server$ echo "JAVA_HOME: $JAVA_HOME"
JAVA_HOME: /path/to/java_jdk
my_user@remote_server$ ./test/test.sh
JAVA_HOME: /path/to/java_jdk
The commands I have configured in the Jenkins SSH plugin
are the exact same as I executed manually:
echo "JAVA_HOME: "$JAVA_HOME
./test/test.sh
But when I run it I get following output in Jenkins:
JAVA_HOME: /data/work/java/jdk1.7.0_45
JAVA_HOME:
Why can't the environment variables be accessed from within the script?
My .profile looks like this
#!/bin/ksh
# ...
export JAVA_HOME=/path/to/java_jdk
# ...