Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|