Import from Trac
Follow the instructions on this page to import tickets from Trac with a Python import script. This procedure requires the following steps:
(Optional) Customize the mapping between the fields in your Trac database and the issue attributes in YouTrack.
The script supports imports from Trac versions 1.2 and later. If are working with an earlier version, you should upgrade your Trac installation first, then import your issues from Trac to YouTrack.
Import Details
If the Trac database 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 | The Python script lets you import all issues from a source project at once. If the project does not already exist, a new project is created.
|
Users | Several issue attributes like
All new user accounts are assigned randomly-generated passwords. To log in to YouTrack, imported users must click the Reset password link on the login page and create a new password. |
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. |
Tags | Keywords in Track are imported as tags. |
Work Items | Trac offers plugins that support time tracking. The import script automatically detects and imports time tracking values from supported plugins. These values are added to imported issues as work items. |
Set Up Your Environment
Import to YouTrack is supported with 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 Python Client Library is 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.
Open the command-line interface that is supported by your operating system.
-
Verify that your Python installation includes the
virtualenv
package by running the following command:pip install virtualenvThis ensures that you are able to execute commands in YouTrack import scripts without encountering a
Command not found
message. Install the package that contains the import scripts with 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
Customize the Mapping Definitions
The next step is to map the fields in your Trac database to attributes in YouTrack.
You only need to customize the mapping file if you have customized the issue attributes in Trac. To use the default mapping definitions, skip this procedure and import your data.
To customize the mapping definitions:
Locate the default mapping file for importing issues from Trac and open it for editing. This file is included in the installation package that contains the import scripts. The file is located in the
youtrackutils/trackLib
subdirectory and is saved asdefaultTrac.py
.Update the mapping to ensure that all of the data that you want to import from the Trac database is mapped to the desired values in YouTrack. If the file contains one or more fields that you don't want to import, you can remove the references from the mapping file. For a description of the default mappings, see Default Mapping.
Set values for the parameters that manage user import:
default_email
— Assigns a default email address to users who are imported without an email.accept_non_authorised_users
— IfTrue
, unregistered users are imported to YouTrack. IfFalse
, unregistered users are imported as guest.
If used, specify the time tracking plugin that is enabled in Trac. The default parameter in the mapping file is set to
support_time_tracking = "auto"
, which detects and imports time tracking values from supported plugins automatically. You can also specify the plugin from which data is imported:Value
Description
trachours
Imports data from the TracHoursPlugin.
timingandestimationplugin
Imports data from the TimingAndEstimationPlugin.
Save your changes and close the mapping file.
Import Your Data
The last step is to run the command that imports your data from Trac.
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:
trac2youtrack target_url target_login target_password project_ID project_name path_to_trac_environmentReplace the command-line parameters with values as described here:
Parameter
Description
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
target_login
The login for a YouTrack administrator account.
target_password
The password for the YouTrack administrator account.
project_ID
The ID of the target project in YouTrack.
project_name
The name of the target project in YouTrack.
path_to_trac_environment
The path to the source project in Trac.
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 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.
Edit your mapping file.
Run the import script again.
Default Mapping
The Python Client Library includes a default mapping file for importing issues from Trac to YouTrack. The file is saved as defaultTrac.py
in the youtrackutils/tracLib
subfolder of the repository.
Ticket Type
Tickets in Trac use the default types defect, enhancement, and task. The default mapping file contains a types
dictionary that maps these values to corresponding values for the Type field in YouTrack.
Pay attention to the following guidelines when you edit this section of the mapping file:
The left side of the mapping references the value for the Type field in Trac. If you have added custom values to this field, add a new definition for each value to the dictionary.
The right side of the mapping references the corresponding values for the Type field in YouTrack. If you specify a value for the Type field that does not already exist, it is added to the field during import.
Ticket Priority
Similar to the mapping for the Type field, this dictionary maps values for the Priority field in Trac to the field with the same name in YouTrack. Follow the same guidelines as for issue type to customize this section of the mapping file. The mapping for default issue priority is as follows:
Ticket Resolution and Status
Values for both the Resolution and Status field in Trac are mapped to values for the State field in YouTrack. The default mapping for these values is as follows:
Ticket Fields
The field_names
dictionary maps field names in Trac to custom fields in YouTrack. You can update the mappings in this section to import data to specific custom fields. The default mapping file only contains definitions for fields that do not match existing fields in YouTrack:
Pay attention to the following guidelines when you edit the custom field mapping:
The left side of the mapping references the field name in Track.
The right side of the mapping references the name of the custom field in YouTrack.
If you do not specify a mapping for a field in Trac that does not match a target field in YouTrack, a custom field is created with the same name as in Trac.
For example, older versions of Trac include a field for Severity. The default mapping file defines the field type but does not map the field to a target field in YouTrack. The field and its values are imported as a new Severity field.
Custom Field Types
The field_types
dictionary maps data types in Trac to custom field types in YouTrack. If you have added fields to the mapping for custom fields, add a corresponding entry to this dictionary to define how the data is stored in YouTrack. The default mapping file contains definitions for the following field types:
Pay attention to the following guidelines when you edit the field type mapping:
The left side of the mapping references the name of the custom field in YouTrack. These values must exactly match the custom field name in the
field_names
dictionary.The right side of the mapping references the field type in YouTrack. For a list of valid types, refer to the Administration REST API.
If the target field already exists in YouTrack, you do not need to include it here.
You cannot change the data type of an existing field. For example, if the existing Assignee field stores single values (
user[1]
), you cannot useuser[*]
in the mapping file and import multiple assignees. You must first update this property for the Assignee field in the YouTrack user interface, then import the data.