我正在使用 jira-connector nodejs模块动态创建JIRA票证:
/**
* Creates a JIRA Issue
* @param {*} jira The jira client.
* @param {string} summary The summary of the ticket.
*/
function createIssueInJira(jira, issueSummary) {
console.log(`Creating JIRA Release Readiness ticket for ${issueSummary}...`)
return new Promise((resolve, reject) => {
jira.issue.createIssue({
issue: { fields: { project: { id: '11111' }, summary: issueSummary, issuetype: { id: '22222' } }}
}, (error, issue) => {
if (error) {
console.log(error);
return reject(error);
}
});
});
}
它一直失败并出现以下错误:
{ errorMessages: [ 'Internal server error' ], errors: {} }
(node:48381) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object]
(node:48381) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
谁能告诉我这里有什么问题?
答案 0 :(得分:2)
回答我自己的问题:只需删除issue:
对象。
/**
* Creates a JIRA Issue
* @param {*} jira The jira client.
* @param {string} summary The summary of the ticket.
*/
function createIssueInJira(jira, issueSummary) {
console.log(`Creating JIRA Release Readiness ticket for ${issueSummary}...`)
return new Promise((resolve, reject) => {
jira.issue.createIssue({
fields: { project: { id: '11111' }, summary: issueSummary, issuetype: { id: '22222' }
},
(error, issue) => {
if (error) {
console.log(error);
return reject(error);
}
});
});
}