Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config file #8

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/
*.so

# Distribution / packaging
.vscode/
.Python
env/
build/
Expand Down Expand Up @@ -87,3 +88,6 @@ ENV/

# Rope project settings
.ropeproject

#config file
config.ini
98 changes: 43 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,65 @@
# JIRA issues importer

Python 2.x scripts for importing JIRA issues in XML format into an existing Github project without existing issues

# Background

Due to the java.net close-down in April 2017 there is a need to move projects from the java.net forge to Github.
Part of the transition is the migration of java.net JIRA issues to the Github issue tracker.
Googling for solutions for this issue migration I came across these "dirty" migration scripts from the following GISTs:

* https://gist.github.com/Jach/1537770
* https://gist.github.com/mkurz/20293e306b1c6fefff7c

I took these as a starting point for this project. I restructured the code and added some more features.
*Python 3.x* scripts for importing JIRA issues in XML format into an existing Github project without existing issues. For Python 2.x, see https://github.com/hbrands/jira-issues-importer.

# Features

* Import JIRA milestones as Github milestones
* Import JIRA labels as Github labels
* Import JIRA components as Github labels
* Import JIRA issues as Github issues where
* issue ids are mapped one by one, e.g. PROJECT-1 becomes GH-1 and PROJECT-4711 becomes GH-4711
* both issue label and component assignments are mapped to Github labels
* issue relationships like "depends on", "blocks" or "duplicates" are mapped to special Github comments
* issue timestamps such as creation, close or update date are considered
* issue states (open or closed) are considered
* issue comments are mapped to Github comments
* JIRA issue references in normal and relationship comments are replaced by references to the Github issue id

# Caveats
* this project does not try to map JIRA users to Github users
* the Github user which performs the import will appear as issue creator, the original JIRA issue reporter is noted in the first comment
* the Github user which performs the import will also appear as comment creator, as the Github API doesn't support that (yet),
* Import
* JIRA milestones as Github milestones
* JIRA labels as Github labels
* JIRA components as Github labels
* JIRA issues as Github issues where
* Issue ids are mapped one by one, e.g. PROJECT-1 becomes GH-1 and PROJECT-4711 becomes GH-4711
* Both issue label and component assignments are mapped to Github labels
* Issue relationships like "depends on", "blocks" or "duplicates" are mapped to special Github comments
* Issue timestamps such as creation, close or update date are considered
* Issue states (open or closed) are considered
* Issue comments are mapped to Github comments
* JIRA issue references in normal and relationship comments are replaced by references to the Github issue id
* Multiple files to help overcome the export limit of 1000 (export multiple files by using the JIRA key column as a range)
* Configure colour scheme for labelling on import

# Caveats
* This project does not try to map JIRA users to Github users
* The Github user which performs the import will appear as issue creator, the original JIRA issue reporter is noted in the first comment
* The Github user which performs the import will also appear as comment creator, as the Github API doesn't support that (yet),
the original JIRA commentator is noted in the comment text
* Labels are case sensitive! If you attempt to import an issue with "Bug" and the label "bug" exists, it will fail. Cases must align.

# Assumptions and prerequisites

* the migration scripts are written in Python 2.x. In particular, they were tested with Python 2.7 on Windows
* python modules used are getpass, collections, lxml, htmlentitydefs, dateutil.parser, re, requests, random, time
* use these scripts at your own risk, no warranties for a correct and successful migration are given
* it's recommended to test your issue migration first with a test project on Github
* input to the import script is the XML export file of your JIRA project, see below
* the import/export was tested with the current java.net JIRA (v6.2.3), other versions might produce different XML export content
* your target Github project should already exist with the issue tracker enabled
* there should be no existing issues and pull requests - else the issue id mapping will be incorrect
* Use these scripts at your own risk, no warranties for a correct and successful migration are given
* It's recommended to test your issue migration first with a test project on Github
* Input to the import script is the XML export file of your JIRA project, see below
* Works with JIRA Cloud, as of March 2019
* Your target Github project should already exist with the issue tracker enabled
* There should be no existing issues and pull requests - else the issue id mapping will be incorrect

# Getting started

* ensure you have installed the proper Python environment with the needed modules
* clone this repository or copy the three Python files main.py, project.py and importer.py to your system
* export the desired JIRA issues of your project (see section below)
* to start the Github import, execute 'python main.py'
* on startup it will ask for
* the JIRA XML export file name
* the JIRA project name
* the Github account name (user or organization)
* the target Github repository name
* the Github user and password for authentication
* the import process will then
* read the JIRA XML export file and create an in-memory project representation of the xml file contents
* import the milestones with the regular [Github Milestone API](https://developer.github.com/v3/issues/milestones/)
* import the labels with the regular [Github Label API](https://developer.github.com/v3/issues/labels/)
* import the issues with comments with the [Github Import API](https://gist.github.com/jonmagic/5282384165e0f86ef105)
* references to issues in the comments are replaced with placeholders in this step
* the used import API will not run into abuse rate limits in contrast to the normal [Github Issues API](https://developer.github.com/v3/issues/)
* post-process all comments to replace the issue reference placeholders with the real Github issue ids using the [Github Comment API](https://developer.github.com/v3/issues/comments/)
* Clone this repository
* Run `pip install -r requirements.txt`
* Export the desired JIRA issues of your project (see section below)
* Edit the `labelcolourselector.py` if you want to change the logic of how the colours are set on labels
* Copy `config.sample.init` as `config.ini`
* Fill out your config values in config.ini. Note that this file is Git ignored.
* Start the Github import by executing 'python main.py'
* The import process will then
* Read the JIRA XML export file and create an in-memory project representation of the xml file contents
* Import the milestones with the regular [Github Milestone API](https://developer.github.com/v3/issues/milestones/)
* Import the labels with the regular [Github Label API](https://developer.github.com/v3/issues/labels/)
* Import the issues with comments with the [Github Import API](https://gist.github.com/jonmagic/5282384165e0f86ef105)
* References to issues in the comments are replaced with placeholders in this step
* The used import API will not run into abuse rate limits in contrast to the normal [Github Issues API](https://developer.github.com/v3/issues/)
* Post-process all comments to replace the issue reference placeholders with the real Github issue ids using the [Github Comment API](https://developer.github.com/v3/issues/comments/)

# Export JIRA issues

1. Navigate to Issue search page for project. Issues --> Search for Issues

1. Select project you are interested in

1. Specify Query criteria, Sort as needed
1. Specify Query criteria, Sort as needed, if you have more than 1000 items use something like eg. `issuekey < PRO-1000 AND issuekey > PRO-2000` to select a range and export each set into separate XML files

1. From results page, click on Export icon at the top right of page

Expand Down
28 changes: 28 additions & 0 deletions config.sample.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Settings]

# JIRA project name to use
jira_project =

# JIRA Done issue status ID
jira_done_id =

# GitHub account name (user or organization)
user_or_org =

# GitHub target repository name
repo_name =

# GitHub access token
#############################################################################################
# WARNING! This is stored in plain text
# To create a token, visit https://github.com/settings/tokens
#############################################################################################
access_token =

# Start from (0 = beginning)
# If you have a failure, enter the index number the import failed at.
# A number > 0 will stop labels from re-importing and milestones will re-match to existing.
start_from_issue =

# Path to JIRA XML query file (semi-colon separate for multiple files)
file_names =
Loading