Import from GitHub
Follow the instructions on this page to import bug reports from GitHub with a Python import script. This procedure requires the following steps:
Import Details
If the GitHub project contains references to entities that do not already exist in YouTrack, they are created. The user account that you use to run the import should have permission to create projects, issues, users, and possibly more. We recommend that you use an account with a System Admin role to execute the import script.
New entities are created as follows:
Entity | Description |
---|---|
Projects | If the project that is referenced in the import source does not already exist, a new project is created.
|
Users | Several issue attributes like reporterName and Assignee store references to user accounts. The values in the import are checked against existing user accounts by email. For each new value that does not match the email for an existing user, a new user account is created.
|
Custom Fields | If the import data contains a field that does not exist in YouTrack, the custom field is created and added to the target project.
|
Field Values | If the source file contains new values for an existing field, they are added to the current set of values. |
Set Up Your Environment
Import to YouTrack is supported by Python import scripts. These scripts are built on top of the YouTrack REST API. You won't actually need to do any programming in Python, but you do need to install Python and the package that contains the import scripts.
To set up your environment:
Download and install Python. The import scripts are compatible with Python 2.7+. Python 3 releases are not supported. You can choose whichever installation directory you prefer.
The latest versions of macOS, CentOS, Red Hat Enterprise Linux (RHEL), and Ubuntu come with Python 2.7 out of the box. If you're working with any of these operating systems, continue with the next step.
Install the package that contains the import scripts. Open the command-line interface that is supported by your operating system and enter the following command:
pip install youtrack-scriptsThe import scripts are installed in your local environment.
The
youtrack
package that contains the Python client library for the YouTrack REST API is installed automatically as a dependency.
If you prefer not to install the packages globally, you can install them for your user account only with the command:
pip install --user youtrack-scripts
Import Your Data
The last step is to run the command that imports your data from GitHub.
To import your data:
Open the command-line interface that is supported by your operating system.
If necessary, change the current directory to the installation directory for Python. For example (Windows):
cd C:\Python27Enter the following command:
github2youtrack -t token -u login -p password target_url github_user github_password github_repoReplace the command-line parameters with values as described here:
Parameter
Description
token
When used with the
-t
option, a permanent token that is used to authenticate your administrator account in YouTrack. This is the preferred method of authentication. If you use this option, skip the-u
and-p
options. To learn how to generate a permanent token, see Create a Permanent Token.Alternatively, you can use the
-T
option and specify the full path and filename for a file that contains a permanent token.login
When used with the
-u
option, the login for a YouTrack administrator account. You must also specify a value for the-p
option.password
When used with the
-p
option, the password for the YouTrack administrator account.target_url
The base URL of the target YouTrack server. For YouTrack InCloud instances, your base URL includes the trailing
/youtrack
. For example:https://company.myjetbrains.com/youtrack
github_user
The username of the account that you use to log in to GitHub.
github_password
The password for the account that you use to log in to GitHub.
github_repo
The name of the GitHub repository that you want to import issues from. If the owner of the repository is not the same user that is specified for the
github_user
parameter, reference the repository with the formatrepo_owner/repo_name
.The command executes the Python import script.
If successful, the following line is printed in the command-line interface for each issue:
Issue [ <issue ID> ] imported successfully
- Check the project or projects that you imported issues into and verify that the data is presented properly. If you are not satisfied with the results and want to re-import the data:
Delete all of the issues that were created during import. If you imported issues into a new project, simply delete the project.
Run the import script again.
Default Mapping
The import script maps data from issues in GitHub to issue attributes in YouTrack. For custom fields, the following mapping is applied:
GitHub | YouTrack |
---|---|
Project Name | project_name |
Project ID | project_id |
Summary | summary |
State | State |
ID | numberInProject |
Created | created |
Updated | updated |
Resolved | resolved |
Assignee | Assignee |
Description | description |
Labels | Labels |
Author | reporterName |
Milestone | Fix versions |
Field | Type |
---|---|
State | state[1] |
Assignee | user[1] |
Labels | enum[*] |
Fix versions | version[*] |
Type | enum[1] |
Troubleshooting
If you encounter any errors when you run the import script, see if any of the following conditions apply.
Condition | Error for [/user/login]: 302: Moved Temporarily |
---|---|
Cause | The value that you used for the |
Solution | Change the value of the target_url parameter and run the import the script again. Use the value that is shown as the Base URL setting for your YouTrack service.
|
Condition | Error for [<resource>]: 403: Forbidden: You have no permissions for <resource> |
---|---|
Cause | The user account that you used to run the import script does not have permission to read or update the target resource. The resource URL indicates which entity is not accessible to the user. |
Solution | Run the import script with a user account that has sufficient permissions to update the target resource. |