Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jira-python - how do you update the fixVersions field?

I'm not sure what I'm doing wrong here, and am hoping someone else has the same problem. I don't get any error, and my json matches what should be correct both on Jira's docs and jira-python questions online. My versions are valid Jira versions. I also have no problem doing this directly through the API, but we are re-writing everything to go through jira-python for cleanliness/ease of use.

This just completely clears the fixVersions field in Jira.

issue=jira.issue("TKT-100")
issue.update(fields={'fixVersions':[{'add': {'name': 'add_me'}},{'remove': {'name': 'remove_me'}}]})

I can add a new version to fixVersions using issue.add_field_value(), but this won't work, because I need to add and remove in one request for the history of the ticket.

issue.add_field_value('fixVersions', {'name': 'add_me'})

Any ideas?

like image 944
user797963 Avatar asked Apr 14 '15 17:04

user797963


2 Answers

Here's a code example of how I got it working for anyone who comes across this later...

    fixVersions = []
    issue = jira.issue('issue_key')
    for version in issue.fields.fixVersions:
        if version.name != 'version_to_remove':
            fixVersions.append({'name': version.name})
    fixVersions.append({'name': 'version_to_add'})
    issue.update(fields={'fixVersions': fixVersions})
like image 124
user797963 Avatar answered Oct 09 '22 03:10

user797963


I did it other way:

  1. Create version in the target project.
  2. Update ticket.

    ver = jira.create_version(name='version_name', project='PROJECT_NAME')
    issue = jira.issue('ISSUE_NUM')
    i.update(fields={'fixVersions': [{'name': ver.name}]})}

In my case that worked.

like image 41
bvrch Avatar answered Oct 09 '22 02:10

bvrch