This repository was archived by the owner on Dec 2, 2020. It is now read-only.
File tree 3 files changed +37
-9
lines changed
3 files changed +37
-9
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ Parameters:
43
43
* ` description ` - a short description of the status
44
44
* ` description_path ` - path to an input file whose data is the value of ` description `
45
45
* ` 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)
47
48
48
49
## Example
49
50
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ eval $( jq -r '{
11
11
"version_status": .version.status
12
12
} | to_entries[] | .key + "=" + @sh "\(.value)"' < /tmp/stdin )
13
13
14
+ #
15
+ # check retry counter
16
+ #
17
+
18
+ REMAINING_TRIES=" ${retry_count:- 5} "
19
+
20
+ while true ; do
14
21
15
22
#
16
23
# lookup
@@ -30,9 +37,24 @@ curlgh "$source_endpoint/repos/$source_repository/commits/$version_commit/status
30
37
# validate
31
38
#
32
39
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} "
35
56
57
+ done
36
58
37
59
#
38
60
# concourse
Original file line number Diff line number Diff line change @@ -91,9 +91,9 @@ jq -c -n \
91
91
# check retry counter
92
92
#
93
93
94
- REMAINING_TRIES=5
94
+ REMAINING_TRIES=" ${retry_count :- 5} "
95
95
96
- while [[ $REMAINING_TRIES -gt 0 ]] ; do
96
+ while true ; do
97
97
98
98
#
99
99
# lookup
@@ -112,17 +112,22 @@ curlgh "$source_endpoint/repos/$source_repository/commits/$source_branch/status"
112
112
# validate
113
113
#
114
114
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
118
123
119
124
#
120
125
# decrease retry counter and loop
121
126
#
122
127
123
128
REMAINING_TRIES=$(( $REMAINING_TRIES - 1 ))
124
129
125
- sleep 1
130
+ sleep " ${retry_timeout :- 3} "
126
131
127
132
done
128
133
You can’t perform that action at this time.
0 commit comments