Skip to content

Commit 24072be

Browse files
dreis2211wilkinsona
authored andcommitted
Improve error handling in JDK upgrade checks
See gh-22110
1 parent bca5ef4 commit 24072be

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ci/scripts/detect-jdk-updates.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/bin/bash
22

3+
report_error() {
4+
echo "Script exited with error $1 on line $2"
5+
exit 1;
6+
}
7+
8+
trap 'report_error $? $LINENO' ERR
9+
310
case "$JDK_VERSION" in
411
java8)
512
BASE_URL="https://api.adoptopenjdk.net/v3/assets/feature_releases/8"
@@ -16,6 +23,10 @@ esac
1623

1724
response=$( curl -s ${BASE_URL}\/ga\?architecture\=x64\&heap_size\=normal\&image_type\=jdk\&jvm_impl\=hotspot\&os\=linux\&sort_order\=DESC\&vendor\=adoptopenjdk )
1825
latest=$( jq -r '.[0].binaries[0].package.link' <<< "$response" )
26+
if [[ ${latest} = "null" || ${latest} = "" ]]; then
27+
echo "Could not parse JDK response: $response"
28+
exit 1;
29+
fi
1930

2031
current=$( git-repo/ci/images/get-jdk-url.sh ${JDK_VERSION} )
2132

@@ -24,9 +35,16 @@ if [[ $current = $latest ]]; then
2435
exit 0;
2536
fi
2637

27-
milestone_number=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/milestones\?state\=open | jq -c --arg MILESTONE "$MILESTONE" '.[] | select(.title==$MILESTONE)' | jq -r '.number')
38+
milestone_response=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/milestones\?state\=open )
39+
milestone_result=$( jq -r -c --arg MILESTONE "$MILESTONE" '.[] | select(has("title")) | select(.title==$MILESTONE)' <<< "$milestone_response" )
40+
if [[ ${milestone_result} = "null" || ${milestone_result} = "" ]]; then
41+
echo "Could not parse milestone: $milestone_response"
42+
exit 1;
43+
fi
44+
45+
milestone_number=$( jq -r '.number' <<< "$milestone_result" )
2846
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster\&milestone\=${milestone_number} )
29-
existing_jdk_issues=$( echo "$existing_tasks" | jq -c --arg TITLE "$ISSUE_TITLE" '.[] | select(.title==$TITLE)' )
47+
existing_jdk_issues=$( jq -r -c --arg TITLE "$ISSUE_TITLE" '.[] | select(has("title")) | select(.title==$TITLE)' <<< "$existing_tasks" )
3048

3149
if [[ ${existing_jdk_issues} = "" ]]; then
3250
curl \

0 commit comments

Comments
 (0)