Skip to content

Commit

Permalink
Merge pull request #38707 from cailafinn/jenkins-agent_arm_mac
Browse files Browse the repository at this point in the history
Fix missed jar path reassignment in jenkins-agent script
  • Loading branch information
SilkeSchomann authored Jan 27, 2025
2 parents 3de2fa8 + 576c4db commit 56d41d8
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions buildconfig/Jenkins/jenkins-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ ARM_JAR_FILE=agent.jar
#####################################################################
# Script
#####################################################################

# 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

# 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
JAR_LOCATION="${JENKINS_URL}/jnlpJars"
JAR_ARGS="-url ${JENKINS_URL} -secret ${SECRET} -name ${NODE_NAME}"
else
JAR_FILE=$LEGACY_JAR_FILE
JAR_LOCATION="${LEGACY_JENKINS_REPO_URL}/${LEGACY_JAR_VERSION}"
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
Expand All @@ -77,12 +95,6 @@ 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}"
Expand All @@ -92,17 +104,6 @@ if [ ! -z "${PROXY_HOST}" ]; then
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
JAR_LOCATION="${JENKINS_URL}/jnlpJars"
JAVA_ARGS="${PROXY_ARGS} -jar ${JAR_FILE} -url ${JENKINS_URL} -secret ${SECRET} -name ${NODE_NAME}"
else
JAR_FILE=$LEGACY_JAR_FILE
JAR_LOCATION="${LEGACY_JENKINS_REPO_URL}/${LEGACY_JAR_VERSION}"
JAVA_ARGS="${PROXY_ARGS} -jar ${JAR_FILE} -jnlpUrl ${AGENT_URL} -secret ${SECRET}"
fi

# find the jar file if it exists
if [ -f ${HOME}/jenkins-linode/${JAR_FILE} ]; then
JAR_FILE=${HOME}/jenkins-linode/${JAR_FILE}
Expand All @@ -123,6 +124,8 @@ else
JAR_FILE=${JAR_FILE_TMP}
fi

JAVA_ARGS="${PROXY_ARGS} -jar ${JAR_FILE} ${JAR_ARGS}"

echo "starting ..."
if [ -z "${JAVA}" ]; then
JAVA=`which java`
Expand Down

0 comments on commit 56d41d8

Please sign in to comment.