diff --git a/README_inbound-agent.md b/README_inbound-agent.md index b45410382..31c471fef 100644 --- a/README_inbound-agent.md +++ b/README_inbound-agent.md @@ -61,6 +61,7 @@ Optional environment variables: * `JENKINS_JAVA_BIN`: Path to Java executable to use instead of the default in PATH or obtained from JAVA_HOME * `JENKINS_JAVA_OPTS` : Java Options to use for the remoting process, otherwise obtained from JAVA_OPTS, **Warning** :exclamation: For more information on Windows usage, please see the **Windows Jenkins Java Opts** [section below](#windows-jenkins-java-opts). +* `JENKINS_AGENT_FILE` : Jenkins agent jar file location, `/usr/share/jenkins/agent.jar` will be used if this is not set * `JENKINS_URL`: url for the Jenkins server, can be used as a replacement to `-url` option, or to set alternate jenkins URL * `JENKINS_TUNNEL`: (`HOST:PORT`) connect to this agent host and port instead of Jenkins server, assuming this one do route TCP traffic to Jenkins controller. Useful when when Jenkins runs behind a load balancer, reverse proxy, etc. * `JENKINS_SECRET`: (use only if not set as an argument) the secret as shown on the controller after creating the agent diff --git a/jenkins-agent b/jenkins-agent index ce9cc815a..6589c25ec 100755 --- a/jenkins-agent +++ b/jenkins-agent @@ -26,6 +26,7 @@ # Optional environment variables : # * JENKINS_JAVA_BIN : Java executable to use instead of the default in PATH or obtained from JAVA_HOME # * JENKINS_JAVA_OPTS : Java Options to use for the remoting process, otherwise obtained from JAVA_OPTS +# * JENKINS_AGENT_FILE : Jenkins agent jar file location, /usr/share/jenkins/agent.jar will be used if this is not set # * REMOTING_OPTS : Generic way to pass additional CLI options to agent.jar (see -help) # # Deprecated environment variables (prefer setting REMOTING_OPTS) @@ -109,6 +110,12 @@ else fi fi + if [ "$JENKINS_AGENT_FILE" ]; then + AGENT_FILE="$JENKINS_AGENT_FILE" + else + AGENT_FILE="/usr/share/jenkins/agent.jar" + fi + # if both required options are defined, do not pass the parameters if [ -n "$JENKINS_SECRET" ]; then case "$@" in @@ -129,6 +136,6 @@ else #TODO: Handle the case when the command-line and Environment variable contain different values. #It is fine it blows up for now since it should lead to an error anyway. - exec $JAVA_BIN $JAVA_OPTIONS -jar /usr/share/jenkins/agent.jar $SECRET $AGENT_NAME $TUNNEL $URL $WORKDIR $WEB_SOCKET $DIRECT $PROTOCOLS $INSTANCE_IDENTITY $REMOTING_OPTS "$@" + exec $JAVA_BIN $JAVA_OPTIONS -jar $AGENT_FILE $SECRET $AGENT_NAME $TUNNEL $URL $WORKDIR $WEB_SOCKET $DIRECT $PROTOCOLS $INSTANCE_IDENTITY $REMOTING_OPTS "$@" fi