NodeJS 使用Jira.js将版本批量分配给多个问题

wixjitnu  于 2023-06-29  发布在  Node.js
关注(0)|答案(1)|浏览(124)

我正在使用jira.js节点库,并已使用它成功地创建了版本和查询问题。现在我想分配的版本,这些问题,但不能得到预期的效果后,一些谷歌和ChatGPT查询。
我试过的是:

import { IssueProperties } from 'jira.js/out/version3'

const issuePropsUpdate = new IssueProperties(jiraClient) // I know jiraClient works
const issueIds = ['123', '456', '789']
const versionId = '101112'

  const res = await issuePropsUpdate.bulkSetIssuesProperties({
    entitiesIds: issueIds.map((issue) => Number(issue)),
    properties: {
      fixVersions: [
        {
          add: {
            id: Number(versionId),
          },
        },
      ],
    },
  })

我确实得到了响应,它告诉我它是成功的,但问题没有发生。以下是此请求的响应:

{
  self: 'REDACTED',
  id: 'REDACTED',
  description: 'Bulk multiple.update of Issue (matching: 33036,33895) property fixVersions',
  status: 'COMPLETE',
  message: 'Bulk update of 2 issues completed',
  result: {
    updatedTotal: 2,
    errors: { errors: {}, errorMessages: [], reasons: [] }
  },
  submittedBy: 10036,
  progress: 100,
  elapsedRuntime: 36,
  submitted: 1687879190262,
  started: 1687879190286,
  finished: 1687879190322,
  lastUpdate: 1687879190322
}

编辑:我已经在github仓库https://github.com/MrRefactoring/jira.js/issues/268上询问了如何做到这一点

flvtvl50

flvtvl501#

我找不到一种使用SDK的方法,所以我自己使用了axios和JIRA REST API

await axios.put(
  `${process.env.ATLASSIAN_API_HOST}rest/api/2/issue/${issue.key}`,
  {
    update: {
      fixVersions: [{ add: { name: version.name } }],
    },
  },
  {
    headers: {
      'Content-Type': 'application/json; charset=utf-8',
      Authorization: `Basic ${Buffer.from(
        `${process.env.ATLASSIAN_EMAIL}:${process.env.ATLASSIAN_API_TOKEN}`,
      ).toString('base64')}`,
    },
  },
)

相关问题