-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-jira-ticket.js
45 lines (39 loc) · 1 KB
/
create-jira-ticket.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
/* eslint-disable @typescript-eslint/no-var-requires */
const https = require('https');
function createJiraTicket() {
const options = {
method: 'POST',
host: process.env.JIRA_BASE_URL,
port: process.env.JIRA_PORT,
path: '/jira/rest/api/2/issue/',
headers: {
Authorization: `Bearer ${process.env.JIRA_API_TOKEN}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
};
const issueData = JSON.stringify({
fields: {
project: {
key: process.env.JIRA_PROJECT_NAME,
},
summary: process.env.PR_TITLE,
description: process.env.PR_DESCRIPTION,
issuetype: {
name: process.env.JIRA_ISSUE_TYPE,
},
},
});
const req = https.request(options, (res) => {
res.setEncoding('utf8');
res.on('data', (body) => {
console.log('Body:', body);
});
});
req.on('error', (e) => {
console.error('problem with request:', e.message);
});
req.write(issueData);
req.end();
}
createJiraTicket();