First of all I must say that I am total noob speaking of Linux and UNIX. Problem that I ran into is that when we deploy our Java application via Jenkins hostname variable is not passed to it. Inside the script somewhere we define HOSTNAME=$(hostname -f) variable, which we use when we start our application - CMD_ARGS=--spring.config.location=file:$CONFIG_HOME/$CONFIG_NAME -Dhostname=$HOSTNAME. In this case, host name is null (I added log in our application). But if I stop application manually and then start it using same script which is used by Jenkins job, hostname variable is passed correctly to java application. So, same script called with same options the only difference is if it is invoked by Jenkins or by myself. In both cases application is started and works correctly, except in case of Jenkins hostname is not passed.
Jenkins deploy doesn't pass variable to java
shell script;java;variable;hostname;jenkins