-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjira.gs
69 lines (64 loc) · 1.91 KB
/
jira.gs
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
function COLLECTDATA(input, method) {
var id = input;
var final = id.substr(id.lastIndexOf('/') + 1);
var ticket = String(final);
var USERNAME = "JIRA USERNAME";
var PASSWORD = "JIRA PASSWORD";
var JIRA_URL = "YOUR JIRA BASE URL";
var API_URL = JIRA_URL+"/rest/api/2/issue/"+ ticket + method;
var authHeader = 'Basic ' + Utilities.base64Encode(USERNAME + ':' + PASSWORD);
var options = {
headers: {Authorization: authHeader}
};
var response = UrlFetchApp.fetch(API_URL, options);
var json = response.getContentText();
var data = JSON.parse(json);
return (data);
}
function GETJIRASUMMARY(input) {
var method = "?fields=summary";
var data = COLLECTDATA(input, method);
return (data["fields"]["summary"]);
}
function GETJIRAREPORTER(input) {
var method = "?fields=reporter";
var data = COLLECTDATA(input, method);
return (data["fields"]["reporter"]["name"]);
}
function GETJIRAPR(input) {
var method = "/comment";
var data = COLLECTDATA(input, method);
var link;
var linkRegExp = /(https:\/\/github.com\/[a-z,0-9]*\/[a-z,0-9]*\/pull\/[a-z,0-9]*)/g;
var count = 0;
var raw = null;
var stop = (data["total"]);
count = stop-1
var author = null;
while (link == null && count <= stop) {
raw = (data["comments"][count]["body"]);
link = linkRegExp.exec(raw);
if (link == null) {
count--;
}};
return (link[0]);
}
function GETJIRAPRAUTHOR(input) {
var method = "/comment";
var data = COLLECTDATA(input, method);
var link;
var linkRegExp = /(https:\/\/github.com\/[a-z,0-9]*\/[a-z,0-9]*\/pull\/[a-z,0-9]*)/g;
var count = 0;
var raw = null;
var stop = (data["total"]);
count = stop-1
var author = null;
while (link == null && count <= stop) {
raw = (data["comments"][count]["body"]);
author = (data["comments"][count]["author"]["name"]);
link = linkRegExp.exec(raw);
if (link == null) {
count--;
}};
return author;
}