-
Notifications
You must be signed in to change notification settings - Fork 0
/
uploadIssues.php
executable file
·81 lines (68 loc) · 1.47 KB
/
uploadIssues.php
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
73
74
75
76
77
78
79
80
81
<?php
include "databaseSupport.php";
include "const.php";
$handle=curl_init();
$headers = array(
'Accept: application/json',
'Content-Type: application/json',
);
curl_setopt_array(
$handle,
array(
CURLOPT_URL=>$base_url.'/rest/api/2/issue/',
CURLOPT_POST=>true,
CURLOPT_VERBOSE=>1,
CURLOPT_SSL_VERIFYHOST=> 0,
CURLOPT_SSL_VERIFYPEER=> 0,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_HEADER=>false,
CURLOPT_HTTPHEADER=> $headers,
CURLOPT_USERPWD=>"$username:$password",
)
);
$result = fetchTempData();
if (! $result){
throw new My_Db_Exception('Database error: ' . mysql_error());
}
$count = 0;
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
echo "<br>$row[1]";
$data = <<<JSON
{
"fields": {
"project":{"key": "{$row[1]}"},
"summary": "{$row[2]}",
"description": "{$row[3]}",
"issuetype": {"name": "{$row[4]}"}
}
}
JSON;
curl_setopt($handle,CURLOPT_POSTFIELDS,$data);
$retval=curl_exec($handle);
$ch_error = curl_error($handle);
if ($ch_error) {echo "cURL Error: $ch_error";}
else
{
$val = json_decode($retval,true);
$error = false;
foreach ($val as $key=>$value)
if($key == "errors")
{$error = true;}
if($error == true)
{
echo "Error in the uploaded data<tb>";
echo $retval;
}
else
{
$count++;
echo "Issue". "{$row[0]}"." is uploaded to main server<br>";
echo $retval;
deleteRecord("{$row[0]}");
}
}
}
curl_close($handle);
echo "<br>Number of issues uploaded are:".$count;
?>