jira-cli icon indicating copy to clipboard operation
jira-cli copied to clipboard

Specify fields displayed by `jira jql "custom_jql"`

Open rasivasu opened this issue 3 years ago • 6 comments

Is it possible to add / remove fields displayed by jira jql "custom_jql"?

rasivasu avatar Jan 26 '21 05:01 rasivasu

try adding following in options object inside config.json

"list_issues_columns": { "Key": { "jsPath": "key" }, "Summary": { "jsPath": "fields.summary", "truncate": 70 }, "assignee": { "jsPath": "fields.assignee.name", "truncate": 15 }, "Status": { "jsPath": "fields.status.name" } },

palashkulsh avatar Jan 26 '21 12:01 palashkulsh

Adding "list_issues_columns" didn't change the output of jira jql custom_jql. Would you also let me know how I can find other possible fieldnames?

    "custom_alasql": {
        "project": "select fields->project->name , count(1)  AS counter from ? group by fields->project->name",
        "priority": "select fields->priority->name , count(1)  AS counter from ? group by fields->priority->name",
        "status": "select fields->project->name,fields->status->name , count(1)  AS counter from ? group by fields->project->name,fields->status->name"
    },
    "list_issues_columns": {
        "Key": { "jsPath": "key" },
        "Summary": { "jsPath": "fields.summary", "truncate": 70 },
        "assignee": { "jsPath": "fields.assignee.name", "truncate": 15 },
        "Status": { "jsPath": "fields.status.name" }
    },

rasivasu avatar Jan 26 '21 16:01 rasivasu

try jira jql customjql -j 1 | jq . | less you must have jq installed otherwise you can just run jira jql customjql -j 1 it gives corresponding json output.

palashkulsh avatar Jan 26 '21 18:01 palashkulsh

If you are really adventurous you could hit the api endpoint to see if there are any hard coded limits:

This line is how we hit the api with rest/api/2/search?jql= https://github.com/danshumaker/jira-cli/blob/master/lib/jira/ls.js#L138

As documented here: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#searching-for-issues-examples And then elaborated on here: https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-fields/

But I guess we should switch our issue search to eventually use: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-jql/#api-group-jql instead.

danshumaker avatar Jan 26 '21 18:01 danshumaker

@palashkulsh Thank you. I am able to see what field names to use from the json.

But defining "list_issues_columns" in config.json didn't change the fields in the output. I checked out the codebase for jira-cli. I don't see the codebase referring to "list_issues_columns". At the same time, I saw the following line in ls.js.

        that.table = new Table({
          head: ['Key', 'Priority', 'Summary', 'Status', 'FixVersions'],

Can you confirm if adding the below lines to config.json will really change the list of fields being displayed in the output?

    "list_issues_columns": {
        "Key": { "jsPath": "key" },
        "Summary": { "jsPath": "fields.summary", "truncate": 70 },
        "assignee": { "jsPath": "fields.assignee.name", "truncate": 15 },
        "Status": { "jsPath": "fields.status.name" }
    },

rasivasu avatar Jan 27 '21 08:01 rasivasu

@rasivasu I also can't see any references to list_issues_columns in the ls.js file (the one responsible for handling the jira jql file) and specifically the getIssues method (the one responsible for creating the table).

As a temporary workaround you could use the --json flag, then, using your scripting language of choice, create something in your profile to parse this json, get the fields your want, then show the table as you wish.

bowdi avatar Apr 12 '21 08:04 bowdi