Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ci/platforms/config.hera
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ export ICSDIR_ROOT=/scratch1/NCEPDEV/global/glopara/data/ICSDIR
export HPC_ACCOUNT=nems
export max_concurrent_cases=5
export max_concurrent_pr=4

export JENKINS_AGENT_LANUCH_DIR=/scratch1/NCEPDEV/global/Terry.McGuinness/Jenkins
export JENKINS_WORK_DIR=/scratch1/NCEPDEV/global/Terry.McGuinness
3 changes: 3 additions & 0 deletions ci/platforms/config.hercules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ export ICSDIR_ROOT=/work/noaa/global/glopara/data/ICSDIR
export HPC_ACCOUNT=nems
export max_concurrent_cases=5
export max_concurrent_pr=4

export JENKINS_AGENT_LANUCH_DIR=/home/role-nems/GFS_CI_ROOT_JENKINS/AGENT_mterry
export JENKINS_WORK_DIR=/home/role-nems/GFS_CI_ROOT_JENKINS
3 changes: 3 additions & 0 deletions ci/platforms/config.orion
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ export ICSDIR_ROOT=/work/noaa/global/glopara/data/ICSDIR
export HPC_ACCOUNT=nems
export max_concurrent_cases=5
export max_concurrent_pr=4

export JENKINS_AGENT_LANUCH_DIR=/home/role-nems/GFS_CI_ROOT_JENKINS/AGENT_mterry
export JENKINS_WORK_DIR=/home/role-nems/GFS_CI_ROOT_JENKINS
76 changes: 76 additions & 0 deletions ci/scripts/utils/launch_java_agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/env bash
set -e

controller_url="https://jenkins.epic.oarcloud.noaa.gov"
controller_user="terry.mcguinness"
HOMEgfs="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." >/dev/null 2>&1 && pwd )"
host=$(hostname)

#########################################################################
# Set up runtime environment varibles for accounts on supproted machines
#########################################################################

source "${HOMEgfs}/ush/detect_machine.sh"
case ${MACHINE_ID} in
hera | orion | hercules | wcoss2)
echo "Launch Jenkins Java Controler on ${MACHINE_ID}"
;;
*)
echo "Unsupported platform. Exiting with error."
exit 1
;;
Comment thread
TerrenceMcGuinness-NOAA marked this conversation as resolved.
Outdated
esac

LOG=lanuched_agent-$(date +%Y%m%d%M).log
rm -f "${LOG}"

source "${HOMEgfs}/ush/module-setup.sh"
module use "${HOMEgfs}/modulefiles"
module load "module_gwsetup.${MACHINE_ID}"
source "${HOMEgfs}/ci/platforms/config.${MACHINE_ID}"

JAVA_HOME="${JENKINS_AGENT_LANUCH_DIR}/JAVA/jdk-17.0.10"
if [ ! -d "${JAVA_HOME}" ]; then
Comment thread Fixed
JAVA_HOME=/usr/lib/jvm/jre-17
if [ ! -d "${JAVA_HOME}" ]; then
Comment thread Fixed
echo "ERROR: JAVA_HOME not found. Exiting with error."
exit 1
fi
fi

JAVA="${JAVA_HOME}/bin/java"
echo "JAVA VERSION: "
${JAVA} -version

export GH="${HOME}/bin/gh"
command -v $GH
Comment thread Fixed
Comment thread Fixed
$GH --version
Comment thread Fixed

if [[ -d "${JENKINS_AGENT_LANUCH_DIR}" ]]; then
echo "Jenkins Agent Lanuch Directory: ${JENKINS_AGENT_LANUCH_DIR}"
else
echo "ERROR: Jenkins Agent Lanuch Directory not found. Exiting with error."
exit 1
fi
cd "${JENKINS_AGENT_LANUCH_DIR}"

if ! [ -f agent.jar ]; then
Comment thread Fixed
curl -sO "${controller_url}/jnlpJars/agent.jar"
fi

JENKINS_TOKEN=$(cat jenkins_token)

offline=$(curl --silent -u "${controller_user}:$JENKINS_TOKEN" "${controller_url}/computer/${MACHINE_ID^}-EMC/api/json?pretty=true" | grep '\"offline\"' | awk '{gsub(/,/,"");print $3}')
Comment thread Fixed
Comment thread Fixed
Comment thread Fixed
echo "Jenkins Agent offline setting: ${offline}"

if [ "${offline}" == "true" ]; then
Comment thread Fixed
echo "Jenkins Agent is offline. Lanuching Jenkins Agent on $host"
Comment thread Fixed
command="nohup ${JAVA} -jar agent.jar -jnlpUrl ${controller_url}/computer/${MACHINE_ID^}-EMC/jenkins-agent.jnlp -secret @jenkins-secret-file -workDir ${JENKINS_WORK_DIR}"
echo -e "Lanuching Jenkins Agent on $host with the command:\n${command}" >& "${LOG}"
Comment thread Fixed
${command} >> "${LOG}" 2>&1 &
nohup_PID=$!
echo "Java agent running on PID: ${nohup_PID}" >> "${LOG}" 2>&1
echo "Java agent running on PID: ${nohup_PID}"
else
echo "Jenkins Agent is online (nothing done)"
fi