sumoheavy / jira-ruby

A Ruby gem for the JIRA REST API
MIT License
656 stars 411 forks source link

How to add a version to an Issue #368

Open jspooner opened 4 years ago

jspooner commented 4 years ago

Is it possible to add a version to an issue? It seems like this should work.

jira = JIRA::Client.new(
  username:     ENV['JIRA_API_USERNAME'],
  password:     ENV['JIRA_API_TOKEN'],
  site:         ENV['JIRA_URI'],
  context_path: '',
  auth_type:    :basic
)
project = jira.Project.find('CC')
target_version = 'Test 1'
version = project.versions.detect { |v| v.name == target_version }

issue = jira.Issue.find('CC-3986')
issue.save fixVersions: [versions]
wisenrico commented 3 years ago

I've accomplished the version change in this way:

issue.save({
  "fields" => {
    "fixVersions" => [{
      "name" => "put your version name here"
    }]
  }
})