-
Notifications
You must be signed in to change notification settings - Fork 0
/
fx_job_script.sh
73 lines (48 loc) · 2 KB
/
fx_job_script.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# 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')
echo "runId =" $runId
if [ -z "$runId" ]
then
echo "RunId = " "$runId"
echo "Invalid runid"
echo $(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})
exit 1
fi
taskStatus="WAITING"
echo "taskStatus = " $taskStatus
while [ "$taskStatus" == "WAITING" -o "$taskStatus" == "PROCESSING" ]
do
sleep 5
echo "Checking Status...."
passPercent=$(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"]|.ciCdStatus')
IFS=':' read -r -a array <<< "$passPercent"
taskStatus="${array[0]}"
echo "Status =" "${array[0]}" " Success Percent =" "${array[1]}" " Total Tests =" "${array[2]}" " Time Taken =" "${array[4]}" " Run =" "${array[5]}"
if [ "$taskStatus" == "COMPLETED" ];then
echo "------------------------------------------------"
echo "Run detail link https://cloud.fxlabs.io"${array[6]}
echo "------------------------------------------------"
echo "${array[7]}"
echo "------------------------------------------------"
echo "Job run successfully completed"
exit 0
fi
done
if [ "$taskStatus" == "TIMEOUT" ];then
echo "Task Status = " $taskStatus
exit 1
fi
echo $(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})
exit 1
return 0