Skip to content

Commit eb40ebd

Browse files
committed
Improve generate_incident script
Adds short delay to allow pagerduty to create the incident It now creates the payload file for you
1 parent b1e891f commit eb40ebd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/generate_incident.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,15 @@ if [ -z "$pd_token" ]; then
8888
exit 0
8989
fi
9090

91-
curl --silent --request GET \
91+
# Pagerduty seems to need a short while to create the incident
92+
# Added this as we intermittently fail to get the incident id otherwise
93+
sleep 2
94+
95+
INCIDENT_ID=$(curl --silent --request GET \
9296
--url "https://api.pagerduty.com/incidents?incident_key=${dedup_key}" \
9397
--header 'Accept: application/json' \
9498
--header "Authorization: Token token=${pd_token}" \
95-
--header 'Content-Type: application/json' | jq -r '.incidents[0].id'
99+
--header 'Content-Type: application/json' | jq -r '.incidents[0].id')
100+
echo $INCIDENT_ID
101+
echo '{"__pd_metadata":{"incident":{"id":"'$INCIDENT_ID'"}}}' > ./payload
102+
echo "Created ./payload"

0 commit comments

Comments
 (0)