-
-
Save jinie/5012377 to your computer and use it in GitHub Desktop.
Updated for redmine 2.2-stable
Added a simple "responsible => username" mapping to set Assignee.
This file contains hidden or 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
import sys | |
import csv | |
import httplib, urllib, base64 | |
def main(): | |
# set the name of your repository, username and password | |
username = "test" | |
password = "test" | |
repo = "test" | |
filename = sys.argv[1] | |
issues = csv.reader(open(filename)) | |
issues_out = [] | |
for issue in issues: | |
issue_map = { | |
"title": issue[6], | |
"content": issue[20] | |
} | |
if issue[4] == "Closed" or issue[4] == "Resolved": | |
issue_map["status"] = "resolved" | |
elif issue[4] == "Rejected": | |
issue_map["status"] = "wontfix" | |
elif issue[4] == "Assigned": | |
issue_map["status"] = "open" | |
elif issue[4] == "New": | |
issue_map["status"] = "new" | |
if issue[2] == "Bug": | |
issue_map["kind"] = "bug" | |
elif issue[2] == "Feature": | |
issue_map["kind"] = "enhancement" | |
elif issue[2] == "Task": | |
issue_map["kind"] = "task" | |
issue_map["responsible"] = username | |
issues_out.append(issue_map) | |
for t in issues_out: | |
print t | |
base64string = base64.encodestring('%s:%s' % (username, password))[:-1] | |
conn = httplib.HTTPSConnection("api.bitbucket.org") | |
headers = {"Content-type": "application/x-www-form-urlencoded", "Authorization" : "Basic " + base64string} | |
url = "/1.0/repositories/%s/%s/issues/" % (username, repo) | |
conn.request("POST", url, urllib.urlencode(t), headers) | |
response = conn.getresponse() | |
print response.status, response.reason | |
conn.close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment