-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_task.js
101 lines (97 loc) · 2.55 KB
/
create_task.js
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var myJson = require('./testExecution.json')
var keys = [];
var status = [];
var obj = {};
const fetch = require('node-fetch')
myJson.getTestExecutions.results.at(0).testRuns.results.forEach(element => {
if (element.status.name == "FAILED") {
keys.push(element.test.jira.key);
status.push(element.unstructured);
}
});
for (var i = 0; i < keys.length; i++) {
obj[keys[i]] = status[i];
}
for (var key of Object.keys(obj)) {
console.log(key + " => " + obj[key] + "</br>")
const bodyData = JSON.stringify(
{
fields: {
"summary": "Error en prueba automatica " + obj[key],
"issuetype": {
"name": "Bug"
},
"project": {
"key": "QM"
},
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Demo",
"type": "text"
}
]
}
]
},
"reporter": {
"accountId": "557058:f4bb59f5-8091-4f11-a936-b31a86e91a1a"
},
"customfield_10501": {
"value": "INTERNO (AOI)"
},
"customfield_11200": {
"value": "INTERNO - Estructura TIMS [2021-15425]"
},
"customfield_12961": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Demo issue fallida",
"type": "text"
}
]
}
]
},
"customfield_12962":{
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Demo issue fallida",
"type": "text"
}
]
}
]
}
}
});
fetch('https://hiberustravel.atlassian.net/rest/api/3/issue', {
method: 'POST',
headers: {
'Authorization': `Basic ${Buffer.from('[email protected]:mkkluihWRmtg8au1JCyY8193').toString('base64')}`,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: bodyData
}).then(response => {
console.log(
`Response: ${response.status} ${response.statusText}`
);
return response.text();
}).then(text => console.log(text)).catch(err => console.error(err));
}