Troubles importing from Google Code
Tried YouTrack Hosted Beta today. First thing I wanted to do was to import issues from Google Code. Found documentation to be very sparse. Eventually I came up with this mapping file:
# mapping for default google code project
import googleCode
print "Use spockframework mapping scheme"
googleCode.STATES = {'New' : 'Submitted',
'Accepted' : 'Open',
'Started' : 'In Progress',
'Fixed' : 'Fixed',
'Duplicate' : 'Duplicate',
'CannotReproduce' : 'Can\'t Reproduce',
'ToBeDiscussed' : 'To be Discussed',
'WaitingForFeedback' : 'To be Discussed',
'NotABug' : 'Won\'t Fix',
'WontFix' : 'Won\'t Fix',
'Invalid' : 'Incomplete'}
googleCode.TYPES = {'Type-Defect' : 'Bug',
'Type-Feature' : 'Feature',
'Type-Task' : 'Task',
'Type-Enhancement' : 'Feature',
'Type-Other' : 'Task'}
googleCode.PRIORITIES = {'Priority-Minor' : '0',
'Priority-Normal' : '1',
'Priority-Medium' : '1',
'Priority-Major' : '2',
'Priority-Critical' : '3'}
googleCode.CUSTOM_FIELDS = {
'Milestone' : {'name': 'Fix Version', 'type' : 'enum[1]', 'isPrivate': False, 'defaultVisibility': True, 'empty' : 'Unscheduled'},
'Module' : {'name': 'Area', 'type' : 'enum[1]', 'isPrivate': False, 'defaultVisibility': True, 'empty' : 'Uncategorized'}}
Not sure about the custom fields. Maybe Milestone and Module should be mapped to what appear to be the corresponding builtin YouTrack fields ('Fix versions' and Subsystem), but I don't know if that's supported.
Import proceeded for a while but reported many errors, most of which appear to be related to custom fields. For example:
Create custom fields
Error for [/admin/customfield/field/Area?isPrivate=False&typeName=enum%5B1%5D&defaultVisibility=True]: 404: Not Found: Custom field type [ null ] not found.
Error for [/admin/project/spock/customfield/Area?emptyFieldText=Uncategorized&bundle=Area]: 404: Not Found: Project [ Area ] not found.
Error for [/admin/customfield/field/Fix%20Version?isPrivate=False&typeName=enum%5B1%5D&defaultVisibility=True]: 404: Not Found: Custom field type [ null ] not found.
Error for [/admin/project/spock/customfield/Fix%20Version?emptyFieldText=Unscheduled&bundle=Fix+Version]: 404: Not Found: Project [ Fix Version ] not found.
And later:
<?xml version="1.0" ?><importReport>...<item id="111" imported="false"><error fieldName="Area">Field is unknown</error><error fieldName="Fix Version">Field is unknown</error>...
And later:
Add tags to imported issues
For issue [103] add tags ['Type-NewFeature']
Error for [/issue/spock-103/execute?command=tag+Type-NewFeature]: 404: Not Found: Issue not found.
Eventually the import failed in the 'transfer attachments' phase:
Transfer attachments
Get issues from 1 to 101
Process issue [1]
Process issue [2]
...
Process issue [55]
Transfer attachment [VarargsMatchingTest.groovy]
Traceback (most recent call last):
File "googlecode2youtrack.py", line 331, in <module>
main()
File "googlecode2youtrack.py", line 49, in main
googlecode2youtrack(source_login, source_password, target_url, target_login, target_password, projectName, projectId)
File "googlecode2youtrack.py", line 317, in googlecode2youtrack
group=None)
File "/swd/app/youtrack-remote-api/python/youtrack/connection.py", line 134, in createAttachment
raise e
urllib2.HTTPError: HTTP Error 404: Not Found
After the import, lots of users had been created in YouTrack, but only two issues. Any pointers on how to improve on this? Definitely needs better documentation.
Please sign in to leave a comment.
Hello, Peter!
The problem is that our Python client library is for Youtrack 2.* . On Hosted YouTrack we run Youtrack EAP, it has some changes in REST API, so you can't use it with library for 2.*. I've attached new library to use it with the EAP.
Attachment(s):
youtrack-remote-api_EAP.zip
Thanks. How do I delete all imported data before importing again? For example, do I have to delete all 50 users manually, one by one? Can't find a bulk delete action.
No, you don't need to delete users of custom fields. You should just delete imported project.
Next error:
...
Create issues [100]
Traceback (most recent call last):
File "googlecode2youtrack.py", line 331, in <module>
main()
File "googlecode2youtrack.py", line 49, in main
googlecode2youtrack(source_login, source_password, target_url, target_login, target_password, projectName, projectId)
File "googlecode2youtrack.py", line 281, in googlecode2youtrack
print target.importIssues(projectId, projectName + ' Assignees', ytissues)
File "/swd/app/youtrack_remote_api_eap/python/youtrack/connection.py", line 261, in importIssues
response = self._reqXml('PUT', url, xml, 400).toxml().encode('utf-8')
File "/swd/app/youtrack_remote_api_eap/python/youtrack/connection.py", line 47, in _reqXml
response, content = self._req(method, url, body, ignoreStatus)
File "/swd/app/youtrack_remote_api_eap/python/youtrack/connection.py", line 38, in _req
response, content = self.http.request(self.baseUrl + url, method, headers=headers, body=body)
File "/swd/app/youtrack_remote_api_eap/python/httplib2/__init__.py", line 1049, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/swd/app/youtrack_remote_api_eap/python/httplib2/__init__.py", line 853, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/swd/app/youtrack_remote_api_eap/python/httplib2/__init__.py", line 822, in _conn_request
conn.request(method, request_uri, body, headers)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 874, in request
self._send_request(method, url, body, headers)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 914, in _send_request
self.send(body)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 719, in send
self.sock.sendall(str)
File "<string>", line 1, in sendall
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 56443: ordinal not in range(128)
Any hints?
The problem is in using unicode characters. If it is just one or two issues that uses them I think it will be easier and faster to you just to correct them. I think I'll fix this issue very soon and attach corrected version to this thread.
I'll wait. No idea which and how many issues are affected.
Hope this fix would help.
Attachment(s):
youtrack-remote-api_EAP.zip
Still the exact same error.
Do you have non-english names for custom field values? And could you please provide the full output of script?
Let's move this to: http://youtrack.jetbrains.net/issue/JT-8265