Keep data in RAM and not worry about file writes. Also no longer
requires the 1 second sleep that the old code needed.
Change-Id: I69c82dc2fda06d0c2b6138807d7a7cf507926648
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
# Make sure we fetch active minions on both the releng and sandbox silos
ACTIVE_MINIONS=()
for silo in releng sandbox; do
# Make sure we fetch active minions on both the releng and sandbox silos
ACTIVE_MINIONS=()
for silo in releng sandbox; do
- JENKINS_URL="https://jenkins.opendaylight.org/$silo/computer/api/json?tree=computer[displayName]"
- wget -nv -O "${silo}_builds.json" "$JENKINS_URL"
- sleep 1 # Need to sleep for 1 second otherwise next line causes script to stall
- ACTIVE_MINIONS=(${ACTIVE_MINIONS[@]} $( \
- jq -r '.computer[].displayName' "${silo}_builds.json" | grep -v master))
+ query="https://jenkins.opendaylight.org/$silo/computer/api/json?tree=computer[displayName]"
+ resp=$(curl -s -w "\n\n%{http_code}" --header "Accept: application/json" "$query")
+ json_data=$(echo "$resp" | head -n1)
+ ACTIVE_MINIONS=(${ACTIVE_MINIONS[@]} $( echo "$json_data" \
+ | jq -r '.computer[].displayName' | grep -v master))
done
#############################
done
#############################
# Make sure we fetch active builds on both the releng and sandbox silos
ACTIVE_BUILDS=()
for silo in releng sandbox; do
# Make sure we fetch active builds on both the releng and sandbox silos
ACTIVE_BUILDS=()
for silo in releng sandbox; do
- JENKINS_URL="https://jenkins.opendaylight.org/$silo//computer/api/json?tree=computer[executors[currentExecutable[url]],oneOffExecutors[currentExecutable[url]]]&xpath=//url&wrapper=builds"
- wget -nv -O "${silo}_builds.json" "$JENKINS_URL"
- sleep 1 # Need to sleep for 1 second otherwise next line causes script to stall
- ACTIVE_BUILDS=(${ACTIVE_BUILDS[@]} $( \
- jq -r '.computer[].executors[].currentExecutable.url' "${silo}_builds.json" \
+ query="https://jenkins.opendaylight.org/$silo//computer/api/json?tree=computer[executors[currentExecutable[url]],oneOffExecutors[currentExecutable[url]]]&xpath=//url&wrapper=builds"
+ resp=$(curl -s -w "\n\n%{http_code}" --header "Accept: application/json" "$query")
+ json_data=$(echo "$resp" | head -n1)
+ ACTIVE_BUILDS=(${ACTIVE_BUILDS[@]} $( echo "$json_data" \
+ | jq -r '.computer[].executors[].currentExecutable.url' \
| grep -v null | awk -F'/' '{print $4 "-" $6 "-" $7}'))
done
| grep -v null | awk -F'/' '{print $4 "-" $6 "-" $7}'))
done