def jira2youtrack(source_url, source_login, source_password, target_url, target_login, target_password, project_id): print("source_url : " + source_url) print("source_login : "******"source_password : "******"target_url : " + target_url) print("target_login : "******"target_password : "******"project_id : " + project_id) source = JiraClient(source_url, source_login, source_password) target = Connection(target_url, target_login, target_password) # # target.createProjectDetailed(project_id, project_id, "", target_login) # # for i in range(0, 5500): # try: # jira_issues = source.get_issues(project_id, i * 10, (i + 1) * 10) # target.importIssues(project_id, project_id + " assignees", # [create_yt_issue_from_jira_issue(target, issue, project_id) for issue in # jira_issues]) # for issue in jira_issues: # process_labels(target, issue) # process_attachments(source, target, issue) # except BaseException, e: # print(str(e)) for i in range(0, 5500): jira_issues = source.get_issues(project_id, i * 50, (i + 1) * 50) links = [] for issue in jira_issues: process_links(target, issue, links) print(target.importLinks(links))
def jira2youtrack(source_url, source_login, source_password, target_url, target_login, target_password, projects, flags, field_mappings, value_mappings): print 'source_url : ' + source_url print 'source_login : '******'target_url : ' + target_url print 'target_login : '******'', target_login) except YouTrackException: pass while True: _end = start + chunk_size - 1 if end and _end > end: _end = end if start > _end: break print 'Processing issues: %s [%d .. %d]' % (project_id, start, _end) try: jira_issues = source.get_issues(project_id, start, _end) start += chunk_size if not (jira_issues or end): break # Filter out moved issues jira_issues = [issue for issue in jira_issues if issue['key'].startswith('%s-' % project_id)] if flags & FI_ISSUES: issues2import = [] for issue in jira_issues: issues2import.append( to_yt_issue(target, issue, project_id, field_mappings, value_mappings)) if not issues2import: continue target.importIssues( project_id, '%s assignees' % project_id, issues2import) except YouTrackException, e: print e continue for issue in jira_issues: if flags & FI_LINKS: process_links(target, issue, issue_links) if flags & FI_LABELS: process_labels(target, issue) if flags & FI_ATTACHMENTS: process_attachments(source, target, issue, flags & FI_REPLACE_ATTACHMENTS > 0) if flags & FI_WORK_LOG: process_worklog(source, target, issue)
def jira2youtrack(source_url, source_login, source_password, target_url, target_login, target_password, project_id, issues_count, skip_count): print("source_url : " + source_url) print("source_login : "******"target_url : " + target_url) print("target_login : "******"project_id : " + project_id) print("issues_count : ", issues_count) print("skip_count : ", skip_count) first_chunk = skip_count / 10 last_chunk = issues_count / 10 if issues_count % 10: last_chunk += 1 source = JiraClient(source_url, source_login, source_password) target = Connection(target_url, target_login, target_password) try: target.createProjectDetailed(project_id, project_id, "", target_login) except YouTrackException: pass for i in range(first_chunk, last_chunk): start = i * 10 + 1 end = (i + 1) * 10 + 1 if start <= skip_count: start = skip_count + 1 if end > issues_count + 1: end = issues_count + 1 try: jira_issues = source.get_issues(project_id, start, end) target.importIssues(project_id, project_id + " assignees", [create_yt_issue_from_jira_issue(target, issue, project_id) for issue in jira_issues]) for issue in jira_issues: try: process_labels(target, issue) except YouTrackException, e: print e try: process_attachments(source, target, issue) except YouTrackException, e: print e try: process_worklog(source, target, issue) except YouTrackException, e: print e