Use regex to get part of a field value with Jira CLI

André Sousa July 10, 2020

Hi!

I am using Jira CLI to automate the project creation. One of the fields in the issue is "Project Category". However, the options in this field don't match exactly to the project categories names configured in Jira. I did a regex pattern that can catch the information that I need.

But how can I do this in Jira CLI and then set my project category with this pattern?

Thank you.

1 answer

0 votes
Michael Kuhl _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2020

Hi @André Sousa - To clarify:  Are you creating projects and setting the "Category" property or creating issues which have a customer field name "Project Category". 
Also, are you using a list (like a CSV file) to create the issues?

André Sousa July 13, 2020

Hi, @Michael Kuhl _Appfire_ !

The first option. I want to set the "Category" property based on a custom field value. The problem is that the categories available in my custom field don't match exactly to the project categories configured in jira.

For example: we have a project category called "IT", but in the custom field is "IT - Information Technology". I need to get just the initials with CLI if possible.

Thank you.

Michael Kuhl _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 13, 2020

So, there isn't an option to transform Jira issue fields when they are output, but you could try this:

  1. Extract the set of values for the custom field to a file using getIssueList with the columns parameter for the field(s) you need and the file parameter to output the values to a file.  
  2. Use copyCsv to do the RegEx transform of the field in the file such that you are left with a new CSV of just the extracted values from the custom field. 
  3. Use runFromCsv with createProject as the common action to create the projects based on the values in the CSV.

Suggest an answer

Log in or Sign up to answer