如今,很少有Web服务或应用程序具有功能,用户可以抱怨(通知,报告)各种类型的内容,无论是文字上的语法错误,措辞错误,不有趣或内容不丰富的内容(例如练习,课程,文章) ,培训材料或部分功能)。能够“报告问题”是使用户参与产品,实施反馈收集形式以及改善整个应用程序所不可或缺的。
所有用户投诉都必须存储在某个地方,确定优先顺序,易于跟踪,并且必须按时处理。但是,总不能为这样的系统的开发和维护分配足够的资源,因为积压的任务总是优先级更高。下面,我将告诉您我们如何使用JIRA REST API 在Uxcel中快速有效地解决此问题。
为什么我们需要“报告问题”?
— ?
Uxcel — - UI/UX . “” — 2 , , — . . (hint — ) (description) , .
— , - , - , , . “ ” , , . , , , , .
, backlog-, , JIRA + REST API.
JIRA
1 BUG JIRA Practices Reports. -. , Label ( : Course, Gym, UEye). :
, - ( ) .
.
JIRA REST API
API token JIRA, JIRA API. , , .
API :
- -> Create
. - , .
API JIRA. , ( ) — HTTP basic authentication.
( TypeScript NodeJS):
private generateAuthHeader(): string {
// email:apiToken Base64
const basicAuthValue = Buffer.from(`${this.jiraEmail}:${this.jiraApiToken}`).toString('base64');
return `Basic ${basicAuthValue}`;
}
: AWS Secrets Manager. . .
API
. , Issue ID JIRA. — GET :
GET https://{id}.atlassian.net/rest/api/3/issuetype
, Postman:
Authorization Type: Basic Auth, email api token.
:
{
"self": "https://{id}.atlassian.net/rest/api/3/issuetype/10004",
"id": "10001",
"description": "A problem or error.",
"iconUrl": "https://${id}.atlassian.net/secure/viewavatar?size=medium&avatarId=10303&avatarType=issuetype",
"name": "Bug",
"untranslatedName": "Bug",
"subtask": false,
"avatarId": 10303
}
Issue Id BUG (“10001”) Project Id, . id .
GET
GET https://{id}.atlassian.net/rest/api/3/project/search
: , (Jira Epic). id , Key ( , , UX-1).
API.
npm Got HTTP NodeJS.
await got.post({
url: `${this.jiraApiHost}/issue`, // jiraApiHost = https://{id}.atlassian.net/rest/api/3
headers: {
Authorization: authorization, // Basic Auth Header generateAuthHeader
'Content-Type': 'application/json'
},
responseType: 'json',
json: {
update: {},
fields: {
issuetype: { id: this.jiraBugTypeId }, // id BUG ( - ‘10001’)
project: { id: this.jiraPracticeReportProjectId }, // id ( - ‘10005’)
parent: { key: this.jiraPracticeReportEpicKey }, // Epic ( - UX-1)
summary: practiceTicketName, // - [practiceId] practiceName (#reports)
labels: [practice.label]
}
}
});
. JIRA, : , , , .
API
API . , , .
:
// JQL , BUG id ( )
const jql = `issuetype = Bug AND project = CNT AND parent = ${this.jiraEpicKey} AND text ~ "${practiceId}" order by created DESC`;
const response = await got.get({
url: `${this.jiraApiHost}/search?jql=${jql}`,
headers: {
Authorization: authorization
},
responseType: 'json'
});
const practiceJiraTicket = response.body['issues'] && response.body['issues'][0];
, , CLOSED.
API
, Transitions. Status ID TODO / OPENED ( JIRA).
Postman:
GET https://{id}.atlassian.net/rest/api/3/project/{projectIdOrKey}/statuses
id , , id.
:
await got.post({
url: `${this.jiraApiHost}/issue/${practiceJiraTicket.key}/transitions`, // practiceJiraTicket -
headers: {
Authorization: authorization,
'Content-Type': 'application/json'
},
responseType: 'json',
json: {
transition: {
id: this.jiraToDoStatusId // id ( - ‘10006’)
}
}
});
— ( , ).
API
, id . . , n — .
API :
await got.put({
url: `${this.jiraApiHost}/issue/${practiceJiraTicket.key}`,
headers: {
Authorization: authorization,
'Content-Type': 'application/json'
},
responseType: 'json',
json: {
update: {
summary: [{ set: newPracticeTicketName }]
}
}
});
.
API
-.
:
await got.post({
url: `${this.jiraApiHost}/issue/${practiceJiraTicket.key}/comment`,
headers: {
Authorization: authorization,
'Content-Type': 'application/json'
},
responseType: 'json',
json: comment //
});
comment Atlassian Document Format.
Builder, : — JSON .
! , , , JIRA.
:
JIRA ( id, #N — , % — ):
. , :
- , JIRA ( AWS SNS)
- priority
- Slack (slack/webhook — )
- JIRA Webhooks, ,
- , .
! , :)
!