How to use a properties file with runFromCsv in Jira Command Line Interface (CLI)

This article explains how to make use of the import.properties file with the runFromCsv action in order to eliminate the manual corrections required to the column names in the CSV file.

Instructions

The propertyFile parameter is used with runFromCsv action to:

  • Allow the column/field name mapping.
  • Allow the data mapping with the field-specific values.The use case below shows how to remove users from the organization in a Jira Service Desk project. Retrieve users list using the getOrganizationUserList action.

The action below creates a CSV file that has the list of users in an organization.

--action getOrganizationUserList --organization "testorg" --file test.csv

The generated CSV file:

  • The action removeOrganizationUsers accepts organization and participants as parameters. As the column User in the CSV file is the same as participants, this change can be mentioned in the import.properties file without manually making the change.
  • The import.properties file here maps the field headings (i.e User) to parameters (i.e. participants) that can be understood by the Command Line Interface (CLI).

  • The left side values are the header names of the CSV file and the right side values are the CLI parameters that are to be mapped.

  • The respective column name should be preceded by field.col_name (i.e. "field.User" in this case).

    Refer to the screenshot of the import.properties file below
  • Run the action below to delete the list of users listed in the CSV file:

     --action runFromCsv --file "test.csv" --common "-a removeOrganizationUsers"  --propertyFile "./src/itest/jira/resources/import.properties"

    If the property file is saved in the ACLI client directory, then the name of the file can be directly mentioned. However, if the file is placed somewhere else, then provide the complete path of the file location.

    Using properties file helps automate the processes eliminating manual interruptions of modifying the CSV input file header names to parameter names accepted by CLI.


It is recommended to test this scenario in a non-production environment or run the action with the --simulate parameter to verify the behavior, before deploying on a production environment.