This repository was archived by the owner on Dec 2, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ Parameters:
4343 * ` description ` - a short description of the status
4444 * ` description_path ` - path to an input file whose data is the value of ` description `
4545 * ` target_url ` - the target URL to associate with the status (default: concourse build link)
46-
46+ * ` retry_timeout ` - the amount of time in seconds to wait while retrying for the status (Default: 3)
47+ * ` retry_count ` - the number of times to retry for the status to be ready (Default: 5)
4748
4849## Example
4950
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ eval $( jq -r '{
1111 "version_status": .version.status
1212} | to_entries[] | .key + "=" + @sh "\(.value)"' < /tmp/stdin )
1313
14+ #
15+ # check retry counter
16+ #
17+
18+ REMAINING_TRIES=" ${retry_count:- 5} "
19+
20+ while true ; do
1421
1522#
1623# lookup
@@ -30,9 +37,24 @@ curlgh "$source_endpoint/repos/$source_repository/commits/$version_commit/status
3037# validate
3138#
3239
33- jq -e ' .status' < /tmp/status > /dev/null \
34- || fatal " Status not found on $( jq -r ' .sha' < /tmp/status ) "
40+ jq -e ' .status' < /tmp/status > /dev/null
41+ check_status=" $? "
42+
43+ if [ " $check_status " -eq 0 ]; then
44+ break
45+ elif [ " $check_status " -gt 0 ] && [ " $REMAINING_TRIES " -le 1 ]; then
46+ fatal " Status not found on $( jq -r ' .sha' < /tmp/status ) "
47+ fi
48+
49+ #
50+ # decrease retry counter and loop
51+ #
52+
53+ REMAINING_TRIES=$(( $REMAINING_TRIES - 1 ))
54+
55+ sleep " ${retry_timeout:- 3} "
3556
57+ done
3658
3759#
3860# concourse
Original file line number Diff line number Diff line change @@ -91,9 +91,9 @@ jq -c -n \
9191# check retry counter
9292#
9393
94- REMAINING_TRIES=5
94+ REMAINING_TRIES=" ${retry_count :- 5} "
9595
96- while [[ $REMAINING_TRIES -gt 0 ]] ; do
96+ while true ; do
9797
9898#
9999# lookup
@@ -112,17 +112,22 @@ curlgh "$source_endpoint/repos/$source_repository/commits/$source_branch/status"
112112# validate
113113#
114114
115- [[ -s /tmp/status ]] \
116- && jq -e ' .status' < /tmp/status > /dev/null \
117- && break
115+ jq -e ' .status' < /tmp/status > /dev/null
116+ check_status=" $? "
117+
118+ if [ " $check_status " -eq 0 ]; then
119+ break
120+ elif [ " $check_status " -gt 0 ] && [ " $REMAINING_TRIES " -le 1 ]; then
121+ fatal " Status not found on $( jq -r ' .sha' < /tmp/status ) "
122+ fi
118123
119124#
120125# decrease retry counter and loop
121126#
122127
123128REMAINING_TRIES=$(( $REMAINING_TRIES - 1 ))
124129
125- sleep 1
130+ sleep " ${retry_timeout :- 3} "
126131
127132done
128133
You can’t perform that action at this time.
0 commit comments