Skip to content

Commit

Permalink
simplified now/force logic and add usage checks
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryMcGuinness-NOAA committed Jul 16, 2024
1 parent f82ccf7 commit 6e412f3
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions ci/scripts/utils/launch_java_agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,7 @@ if [[ ! -f "${controller_user_auth_token}" ]]; then
echo "User Jenkins authetication TOKEN to the controller for using the Remote API does not exist"
exit 1
fi

JENKINS_TOKEN=$(cat "${controller_user_auth_token}")
curl_response=$(curl --silent -u "${controller_user}:${JENKINS_TOKEN}" "${controller_url}/pluginManager/api/json?pretty=true") || true
if [[ "${curl_response}" == "" ]]; then
echo "ERROR: Jenkins controller not reachable. Exiting with error."
exit 1
else
echo "${curl_response}"
fi

echo -e "#!/usr/bin/env python
import json,sys
Expand All @@ -154,6 +146,10 @@ chmod u+x parse.py
check_node_online() {
rm -f curl_response
curl_response=$(curl --silent -u "${controller_user}:${JENKINS_TOKEN}" "${controller_url}/computer/${MACHINE_ID^}-EMC/api/json?pretty=true") || true
if [[ "${curl_response}" == "" ]]; then
echo "ERROR: Jenkins controller not reachable. Exiting with error."
exit 1
fi
echo -n "${curl_response}" > curl_response
./parse.py curl_response
}
Expand All @@ -167,25 +163,24 @@ lauch_agent () {
echo "Java agent running on PID: ${nohup_PID}" >> "${LOG}" 2>&1
}

if [[ "${force_launch}" == "true" ]]; then
lauch_agent
exit
fi
if [[ "${force_launch}" == "true" ]]; then
lauch_agent
exit
fi

offline=$(set -e; check_node_online)

if [[ "${offline}" != "False" ]]; then
if [[ "${skip_wait}" != "True" ]]; then
if [[ "${offline}" != "False" ]]; then
if [[ "${skip_wait}" != "True" ]]; then
echo "Jenkins Agent is offline. Waiting 5 more minutes to check again in the event it is a temp network issue"
sleep 300
offline=$(check_node_online)

Check notice

Code scanning / shellcheck

Bash implicitly disabled set -e for this function invocation because it's inside a command substitution. Add set -e; before it or enable inherit_errexit. Note

Bash implicitly disabled set -e for this function invocation because it's inside a command substitution. Add set -e; before it or enable inherit_errexit.
fi
if [[ "${offline}" != "False" ]]; then
fi
if [[ "${offline}" != "False" ]]; then
lauch_agent
else
echo "Jenkins Agent is online (nothing done)"
fi
fi
else
echo "Jenkins Agent is online (nothing done)"
fi
fi

0 comments on commit 6e412f3

Please sign in to comment.