forked from shoukathmd/FX-Job-Invc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jq_example.sh
66 lines (37 loc) · 1.04 KB
/
jq_example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
# Begin
FX_USER=$1
FX_PWD=$2
FX_JOBID=$3
REGION=$4
TAGS=$5
SUITES=$6
CATEGORIES=$7
echo "user=${FX_USER}"
echo "region=${REGION}"
echo "jobid=${FX_JOBID}"
runId=$(curl -k --header "Content-Type: application/json;charset=UTF-8" -X POST -d '{}' -u "${FX_USER}":"${FX_PWD}" https://cloud.fxlabs.io/api/v1/runs/job/${FX_JOBID}?region=${REGION} | jq -r '.["data"]|.id')
if [ -z "$runId" ]
then
echo "RunId = " "$runId"
echo "Invalid runid"
fi
status="WAITING"
echo "status = " "WAITING"
while [ "$status" = "WAITING" -o "$status" = "PROCESSING" ]
do
sleep 10
status=$(curl -k --header "Content-Type: application/json;charset=UTF-8" -X GET -u "${FX_USER}":"${FX_PWD}" https://cloud.fxlabs.io/api/v1/runs/${runId} | jq -r '.["data"]|.task.status')
echo "status = " $status
if [ $status = "COMPLETED" ];then
echo "Job run successfully completed"
exit 0
fi
done
if [ $status = "TIMEOUT" ]
then
exit 1
else
exit 0
fi
return 0