Import from Bugzilla
- Set up your local environment.
- Customize the mapping between the fields in your Bugzilla database and the issue attributes in YouTrack.
- Import your issues.
If the Bugzilla 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:
|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 |
References to users in the imported data are mapped to existing accounts in YouTrack. If a match is not found, a new user account is created.
Imported users are allocated a license according to your subscription plan. For users that exceed your per-user license limit, the imported users are flagged as banned.
For more information, see Ban User Accounts.
|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 the YouTrack Python Client Library. This library is basically a wrapper for the YouTrack REST API. You won't actually need to do any programming in Python, but you do need to install Python and download the client library.
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.
- Install a Python library for the MySQL database. For example, MySQLdb.
- Download the latest version of the YouTrack Python Client Library from GitHub.
- Extract the contents of the ZIP archive to a folder in your local directory. You can extract the files to whichever folder you prefer.
Customize the Mapping Definitions
The next step is to map the fields in your Bugzilla database to issue attributes in YouTrack. The client library contains a sample file that you can customize to match your import data. The file is saved as
defaultBzMapping.py in the
python/bugzilla subfolder of the client library. This file contains mappings for all of the fields that are required for successful import and definitions for most custom field types.
To use the default mapping definitions, skip this procedure and import your data.
To customize the mapping definitions:
- Either open the
defaultBzMapping.pyfile or open a new file in a text editor and paste the content of the default mapping file.
- Verify that all of the data in your Bugzilla database is mapped to the desired values in YouTrack. For a description of the default mappings, see Default Mapping.
- Check that the value for the
bugzilla.BZ_DB_CHARSETparameter matches the character encoding for your Bugzilla database. Bugzilla versions 2.22 and later use UTF-8 character encoding.
- If you created a new file, perform the following steps:
- Save your mapping file with the extension
.pyand add it to the
<unzipped library directory>/python/bugzilladirectory.
- Open the bugzilla2youtrack.py file in the python subfolder of the client library.
- Locate the reference to the
mantismodule and set the value to the name of your mapping file (without the
.pyextension). Use the following example as a guide:
import calendar import youtrack from youtrack.connection import Connection from bugzilla.bzClient import Client from youtrack import * from StringIO import StringIO import bugzilla.<mapping file name> import bugzilla import sys import os from youtrack.importHelper import create_custom_field, process_custom_field
- Save and close the mantis2youtrack.py file.
defaultBzMapping.pyfile instead, save and close the file.
- Save your mapping file with the extension
Import Your Data
The last step is to run the command that imports your data from Bugzilla.
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):
- Enter the following command: Replace the command-line parameters with values as described here:
python bugzilla2youtrack.py target_url target_login target_pass bz_db bz_host bz_port bz_login bz_pass [bz_product]
The base URL of the target YouTrack server. For YouTrack InCloud instances, your base URL includes the trailing
/youtrack. For example:
The login for a YouTrack administrator account.
The password for the YouTrack administrator account.
The name of the source database to import from Bugzilla. The default database name is
The URL of the Bugzilla source database.
The port to access the Bugzilla source database. If not configured specifically, the default port number is 3306.
The username to log in to the Bugzilla source database.
The password for the account used to log in to the Bugzilla source database.
The optional name of the source product to import from Bugzilla. To import multiple projects, separate project names with commas.
If empty, all products in the database are imported.
- 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.
- Edit your mapping file.
- Run the import script again.
The Python Client Library includes a default mapping file for importing bugs from Bugzilla to YouTrack. The file is saved as
defaultBzMapping.py in the
python/bugzilla subfolder of the client library.
The import script
bugzilla2youtrack.py contains a reference to the default mapping file. If you create a custom mapping file with a different name, update the reference to the mapping file in the script as described in the above procedure.
Status and Resolution
Values for bug Status and Resolution in Bugzilla are imported to their respective custom fields in YouTrack as fields that store a
state type. The values for these fields are mapped as follows:
|Bugzilla Status||YouTrack State|
|Bugzilla Resolution||YouTrack State|
Custom Field Types
The definitions for field types in Bugzilla are mapped to specific field types in YouTrack.
|Bugzilla CF_TYPE (numeric)||Bugzilla CF_TYPE||YouTrack Field Type|
FIELD_TYPE_BUGID (numeric id "6") field type in Bugzilla is imported to YouTrack an issue link. If you prefer a different mapping, define it manually in your mapping file.