Jira

From Starfish ETL
Jump to navigation Jump to search

Connector

The Jira connector is fairly standard. It asks for your username, password and URL. Your URL will be something like: https://starfishetl.atlassian.net. Your "password" may not be your password. In some, or all, accounts, you must supply an API key as your password. To generate an API key, as of this writing, open the "Settings" gear icon -> Atlassian Account Settings -> Security -> Create and manage API tokens. Create a Token for Starfish to use and put that into the "password" field. You can also use the "Authorize" button.

The connector is based on a DLL from CData. See documentation here: https://cdn.cdata.com/help/BJJ/ado/.

Origin Filters

When Querying Issues, it is supposed to use Jira Query Language: https://www.atlassian.com/blog/jira-software/jql-the-most-flexible-way-to-search-jira-14. It seems to follow these rules, but some trial and error may be required. Also note that sometimes, fields queried on do not seem to match what is returned. For example, when looking at a records returned values, you may see "fields.updated". To filter on that field, you have to use "updatedDate". I'm not sure how to find where or why this occurs. I used Google.

Custom Fields

To filter by a custom field, use cf[FIELDID]. Example:

cf[10100]~'47'

Date Time

To filter by Date/Time, Use:

updatedDate>="2021-08-12 10:40"

Please note that Jira Query Language does NOT support seconds. See this post: https://community.atlassian.com/t5/Jira-questions/Jira-API-JQL-Datetime-Format-Doesn-t-Support-Seconds-and/qaq-p/1476275. Even though seconds are not supported, it seems to filter by the seconds equaling 00. This has the effect of making > and >= behave the same. Because you are saying > ...:00 or >= ...:00. I suppose it might make a difference if the date you are filtering on happened at exactly ...:00. I'm going to stick with >= just to be sure.

Sorting

Append "order by FIELD ASC/DESC" to your Criteria. Example:

order by updated ASC

Inserting a File

To insert a file, create an Insert Stage for the attachment table. Pass the file to the attachment byte[] field. In this case, I was reading from SugarCRM, so I did not need to convert the object returned by the Smart Lookup.

object ScriptedField()
{
    string result;
    result = "";
	object att;
	byte[] data = Encoding.ASCII.GetBytes("");
	//Starfish.LogMessage(Starfish.GetJSON(attachmentIndex,"id"));
	att = Starfish.SmartLookup("Notes","attachment","[{\"id\":\"" + Starfish.GetJSON(attachmentIndex,"id") + "\"}]",false,"","ORIGIN");
	if (att == null) {
        //If the returned object is null, we do not want to insert no attachment.
       Starfish.GotoNextRow();
    }
	return att;
}