MrRefactoring / jira.js

A JavaScript/TypeScript wrapper for the JIRA Cloud, Service Desk and Agile REST API
https://mrrefactoring.github.io/jira.js/
MIT License
349 stars 46 forks source link

Struggling to Set FixVersion on issues #268

Closed littlespice33 closed 10 months ago

littlespice33 commented 1 year ago

I'm working on a script that creates a version and then assigns that as the fixVersion to many issues. I can't figure out a way to assign the fixVersion and the documentation hasn't helped me out much (or I've been looking in the wrong spots), I tried checking it out at https://mrrefactoring.github.io/jira.js/classes/Version3.IssueProperties.html#setIssueProperty and it only accepts an issue key and a property name but it doesn't allow for a value.

I also tried to check out https://mrrefactoring.github.io/jira.js/interfaces/Version3.Version3Parameters.BulkSetIssuesProperties.html a but couldn't figure out what to put inside the properties object in order to properly set the fixVersion.

What am I missing? Does this feature exist yet?

littlespice33 commented 1 year ago

Workaround for me was to use axios and just make a request to the 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')}`,
    },
  },
)
MrRefactoring commented 10 months ago

Hello @littlespice33! I finally got to your issue. It looks like you've messed up the API a bit and you need to use editIssue instead of setIssueProperty

MrRefactoring commented 10 months ago

The example:

client.issues.editIssue({
  issueIdOrKey: issue.key,
  update: {
    fixVersions: [{ add: { name: version.name }}]
  },
});
littlespice33 commented 10 months ago

That did indeed work! Sorry I got lost in the sauce of the documentation and I feel I should have been able to find that function myself. Thank you!

MrRefactoring commented 10 months ago

It's okay, thank you for question!