Database import

This page is about Assets & Inventory Plugin for Jira DC. Using Cloud? Click here.

This guide explains how to import assets and keep them synchronized with a database or Configuration Management Database (CMDB) tool.

Set up database synchronization

  1. Navigate to Settings > External System Configuration.

  2. Click Add Database Configuration.

  3. Define the connection details.

  1. Name: Enter a recognizable name for this configuration (for example, Production Database).

  2. URL: Provide the database connection URL. Refer to your database provider's documentation for specific URL formats (for example, PostgreSQL: jdbc:postgresql://localhost:5432/jira8.5.1).

  3. Driver: Specify the JDBC driver class required to connect to your database.

    • Download the appropriate driver JAR file.

    • Place the JAR file in the Jira installation directory under the lib folder.

    • Restart Jira for the changes to take effect.

Database

Driver Class

Description

Database

Driver Class

Description

Microsoft SQL Server

com.microsoft.sqlserver.jdbc.SQLServerDriver

 

MySQL

com.mysql.jdbc.Driver

com.mysql.cj.jdbc.Driver

Connector/J version 5.1

Connector/J version 8

See https://dev.mysql.com/doc/connector-j/en/connector-j-versions.html for more information.

PostgreSQL

org.postgresql.Driver

 

Oracle

oracle.jdbc.OracleDriver

 

  1. User: Enter the username with access to the database.

  2. Password: Provide the password for the specified user. (Note: Password is encrypted during storage. Anytime you want to edit a configuration, you must enter the password again.)

  3. Cron Expression: Schedule synchronization using a cron expression (for example, 0 0 * * * for daily sync at midnight).

  4. Acting Jira User: Select a Jira user with permissions to create, update, and delete assets.

  5. Is Active: Enable or disable synchronization for this configuration.

  6. Test Connection: Verify the connection details by clicking Test Connection.

  7. Click Save.

Asset Type mapping

  1. Click Assets > Settings > External System Configuration.

  2. After creating a database configuration, select its name.

  3.  Click Configure to access the mapping options.

  4. Define mapping details.

  5. Name: Assign a descriptive name for this mapping (for example, Import Servers).

  6. Asset Type: Select the Jira asset type you want to populate with data from the database.

  7. Selector: The selector is an SQL query. Write an SQL query to retrieve data from your database table. You can test and refine these queries directly in a database client tool. Data will be fetched from this execution result.

Database

Example

Database

Example

Microsoft SQL Server

Select * FROM Northwind.dbo.Customers

MySQL

SELECT * FROM employees

Oracle

SELECT * FROM products

PostgreSQL

SELECT * FROM “inventory_example”

Additional columns (not on the table) – You can add constant values to the query or database functions to add calculated values as columns. For example, you can add status and substatus static values to the query where they are not in the table.

select t.*, 'In stock' as c_status, 'Available' as c_substatus from assets.t_service_category t

Notes:

  • Please try SQL queries on a database client first.

  • Consider database schema requirements (tables or views) before defining selectors.

  1. Date Format: Specify date formats (for example, yyyy-MM-dd for 1994-01-17) if your database stores these values in character fields. Refer to SimpleDateFormat (Java SE 10 & JDK 10 ) for formatting options.

  2. Date Time Format: Specify date-time formats (for example, yyyy-MM-dd hh:mm:ss.s for 1994-01-17 09:00:00.0) if your database stores these values in character fields. Refer to SimpleDateFormat (Java Platform SE 8 ) for formatting options.

  3. Delimiter: If multiple values are kept in a character field, a delimiter (for example, comma) will split them while importing. Delimiter provides importing multiple select attributes like Checkbox and List Box - Multiple.

  4. Define Non-Existing Attribute Options: When the imported value is not an option for the attribute, this option allows you to define these values as a new option for attributes like Checkbox, Dropdown List, List Box, List Box - Multiple, and Radio Button.

  5. Ignore Attribute Existence: When an attribute is not defined in the Asset Type Schemes of the selected Asset Type, this option allows the asset to be created without undefined attribute value. Otherwise, the asset will not be created.

  6. Delete Missing Objects: This option provides full synchronization with the database. If enabled, the synchronization system will delete the manually created assets (the assets that are not imported from the database) in the selected Asset Type.

  7. Update Multiple Objects: Identifiers provide the Asset Uniqueness. When multiple assets are found with the identifier search, this option decides whether all found assets will be updated or none of them.

  8. Ignore Empty Values: Prevent empty values from being imported.

  9. Ignore Invalid Values: When an imported value is not invalid for an attribute, the asset will not be created. With this option, the asset will be created without the attribute, which has an invalid value.

  10. Is Active: Enable or disable synchronization for this specific Asset Type Mapping. (Note: Asset Name Field Mapping must be defined for activation.)

  11. Click Save.

Field mapping

This allows you to define how data from your database columns will be used to populate attributes in your assets.

  1. Navigate to Assets > Settings > External System Configuration.

  2. Go to the database configuration you’ve created, and expand it.

  3. Click Create new Field Mapping.

  4. Define mapping details.

  5. Attribute Name: Select the Jira asset type attribute you want to import data for.

If Asset List or Asset List by Form is selected as Attribute, these fields will appear:

  • Referenced Asset Match Type: Decide which way to fill asset list fields.

If the Match with Query Column is selected:

  • The asset name search will be held with the imported value. For example, referenceAssets("asset.name", "imported value").

  • When Multiple Asset Found, Match: With the given parameters, if multiple assets are found in the search result, decide match:

          ALL: References all found assets

          FIRST: References the assets with the lowest ID

          NONE: References none of them

  • Query/Scripted Column: With this field, it is possible to find the assets that you want to reference with search functions. Each line is accepted as a different search. Each search result will be referenced on the Attribute.

    referenceAsset("asset.name", "${asset_name}", "Country", "Turkey", "City", "${city}) referenceAssetByType("Employee", "asset.name", "${asset_name}")To perform an EXACT query, surround the variable with an escaped double quotes: "\"${c_emp_id}\""For example:Search ScriptCurrent row valueAssets to match matchreferenceAssetByType("Employee", "Employee ID", "${c_emp_id}")Emp 001Emp 001Emp 002referenceAssetByType("Employee", "Employee ID", "\"${c_emp_id}\"")Emp 001Emp 001

    The value between "${}" must be the name of the column of the database from where you get the search parameter.

Example:

The referenceAsset() function in the first line of the Scripted Column retrieves the asset.name and City fields from the "asset_name" and "city" columns in the database.

If the Match with Scripted Column is selected:

  1. Query Column: Choose the column containing the data to import.

  1. Delimiter: Define a delimiter (if needed) to separate multiple values imported into list-based attributes. This field is available for Asset List, Asset List By Form, Checkbox, List Box - Multiple, and Jira Multiple Users attributes. 

  2. Concatenator: Use this to combine data from multiple database columns into a single attribute value in Jira.

  1. Is Identifier: This searches if the imported asset exists in the system. If the asset exists, it will be updated. If not, a new asset will be created.

  2. Click Save.