Skip to content

Commit

Permalink
Assign the jar file before checking if it's running
Browse files Browse the repository at this point in the history
  • Loading branch information
cailafinn committed Jan 27, 2025
1 parent bcc9cf1 commit 576c4db
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions buildconfig/Jenkins/jenkins-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,13 @@ 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
echo "Usage: `basename ${0}` <NODE_NAME> <SECRET> [PROXY_HOST] [PROXY_PORT]"
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
Expand All @@ -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}
Expand Down

0 comments on commit 576c4db

Please sign in to comment.