diff --git a/buildconfig/Jenkins/jenkins-agent.sh b/buildconfig/Jenkins/jenkins-agent.sh index bdfd85034384..b37496c4fabc 100644 --- a/buildconfig/Jenkins/jenkins-agent.sh +++ b/buildconfig/Jenkins/jenkins-agent.sh @@ -68,14 +68,6 @@ ARM_JAR_FILE=agent.jar ##################################################################### # Script ##################################################################### -# exit if it is already running -RUNNING=$(ps u -U $(whoami) | grep java | grep ${JAR_FILE}) -if [ ! -z "${RUNNING}" ]; then - echo "Agent process is already running" - exit 0 -else - echo "Agent process is not running" -fi # error out if there isn't a node name and secret if [ "$#" -lt 2 ]; then @@ -83,15 +75,6 @@ if [ "$#" -lt 2 ]; then exit -1 fi -# setup the proxy -if [ ! -z "${PROXY_HOST}" ]; then - PROXY_ARGS="-Dhttps.proxyHost=${PROXY_HOST} -Dhttps.proxyPort=${PROXY_PORT}" - echo "using proxy ${PROXY_HOST} ${PROXY_PORT}" - # For curl - export http_proxy=http://$PROXY_HOST:$PROXY_PORT - export https_proxy=https://$PROXY_HOST:$PROXY_PORT -fi - # macOS agents with ARM architecture need to run the newer agent.jar file. if [[ "$OSTYPE" == "darwin"* ]] && [[ $(uname -m) == 'arm64' ]]; then JAR_FILE=$ARM_JAR_FILE @@ -103,6 +86,24 @@ else JAR_ARGS="-jnlpUrl ${AGENT_URL} -secret ${SECRET}" fi +# exit if it is already running +RUNNING=$(ps u -U $(whoami) | grep java | grep ${JAR_FILE}) +if [ ! -z "${RUNNING}" ]; then + echo "Agent process is already running" + exit 0 +else + echo "Agent process is not running" +fi + +# setup the proxy +if [ ! -z "${PROXY_HOST}" ]; then + PROXY_ARGS="-Dhttps.proxyHost=${PROXY_HOST} -Dhttps.proxyPort=${PROXY_PORT}" + echo "using proxy ${PROXY_HOST} ${PROXY_PORT}" + # For curl + export http_proxy=http://$PROXY_HOST:$PROXY_PORT + export https_proxy=https://$PROXY_HOST:$PROXY_PORT +fi + # find the jar file if it exists if [ -f ${HOME}/jenkins-linode/${JAR_FILE} ]; then JAR_FILE=${HOME}/jenkins-linode/${JAR_FILE}