Skip to content

Commit

Permalink
Add migrate-target-versions example
Browse files Browse the repository at this point in the history
  • Loading branch information
a13m committed Mar 14, 2013
1 parent 40e049f commit 2783dc1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions migrate-target-versions.py
@@ -0,0 +1,30 @@
from jiraauth import jclient
import debugmode

"""
This script was used to copy target versions (customfield_10304)
into the fix version field. It's a decent example of how to
iterate over search results and update issues in the result set
"""

i = 0
maxResults=50
num = 50
while i < num:
num, results = jclient.search_issues_with_total('"Target Version/s" is not EMPTY and status not in (Resolved, Closed)', startAt=i)
for issue in results:
print "checking " + issue.key
newFixVersions = None
for target_version in issue.fields.customfield_10304:
if not len([ x for x in issue.fields.fixVersions if x.id == target_version.id ]):
if not newFixVersions:
newFixVersions = [ x for x in issue.fields.fixVersions ]
newFixVersions.append(target_version)
if newFixVersions:
print "Updating " + issue.key + " was " + \
",".join(sorted([x.name for x in issue.fields.fixVersions ])) + \
" now " + ",".join(sorted([x.name for x in newFixVersions ]))
issue.update(fixVersions=[ { 'name': x.name } for x in newFixVersions ])
i += maxResults
print i

0 comments on commit 2783dc1

Please sign in to comment.