代码之家  ›  专栏  ›  技术社区  ›  Ivory Micky

使用Jira连接器nodejs模块动态创建Jira问题

  •  1
  • Ivory Micky  · 技术社区  · 6 年前

    我正在使用 jira连接器 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.
    

    有人能告诉我这里出了什么问题吗?

    1 回复  |  直到 6 年前
        1
  •  3
  •   Ivory Micky    6 年前

    回答我自己的问题:只需要删除 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);
              }
            });
          });
        }