Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save queries in configuration file #99

Closed
williamh opened this issue Jul 19, 2017 · 7 comments
Closed

save queries in configuration file #99

williamh opened this issue Jul 19, 2017 · 7 comments

Comments

@williamh
Copy link

My co-worker and I cane up with another possible enhancement to this tool.

The -q option allows jql on the command line. It would be cool if there were a way to save jql queries in .jira.d and refer to them by name on the command line.

We could use a command line option, for example -Q (note upper case) to refer to a query like this:

jira ls -Q myquery

I thought about saving the queries themselves in config.yml, but I'm not sure if that would work or what the syntax would be. My thought is a "queries" dictionary in which the key is the name and the value is the jql query itself, but I'm not quite sure what that would look like.

What are your thoughts about something like this? If you give me the information, I may look into submitting a pull request for this.

Thanks,

William

@williamh
Copy link
Author

Ok, it looks like we couldn't use -Q for this, because it is already used for --quiet.

@gvol
Copy link
Contributor

gvol commented Jul 31, 2017

Something like the following works for me to allow usage like jira foo and jira bar:

# Default configuration here...


# Only for certain types
case $JIRA_OPERATION in

    foo)
        cat <<EOF
command: list
query: filter = 12345
EOF
        ;;

    bar)
        cat <<EOF
command: list
query: user = currentUser() and Sprint in openSprints()
EOF
        ;;
esac

@williamh
Copy link
Author

williamh commented Aug 1, 2017

I am looking for a convenient way to list all tickets assigned to me that are not resolved. How do you suggest doing this?

Thanks much,

William

@gvol
Copy link
Contributor

gvol commented Aug 9, 2017

Here's an abbreviated and redacted version of what I have, which allows me to run jira mine and see what's assigned to me. I save a filter in Jira that links to my issues (numbered 12345 in this example).

#!/usr/local/bin/bash

cat <<EOF
endpoint: https://jira.xxxx.xxxx/
project: XXX
components: XXXX
priority: Normal
EOF

case $JIRA_OPERATION in
    mine)
        cat <<EOF
command: list
query: filter = 12345
EOF
        ;;
esac

I find it works quite well.

@coryb
Copy link
Contributor

coryb commented Sep 7, 2017

I have created an example for how to create jira mine command to list issues assigned to you:
https://github.com/Netflix-Skunkworks/go-jira#examples

It no longer uses the executable config file, but that mechanism should still work.

Still thinking named queries might be useful also, perhaps something like:

named-queries:
  foo: filter = 12345
  bar: user = currentUser() and Sprint in openSprints()

Then modify the list/edit usage to access the via:

jira ls -N foo
jira ls --named foo

@coryb
Copy link
Contributor

coryb commented Sep 13, 2017

Added named queries into .jira.d/configs.yml:

queries:
  todo: |
    resolution = unresolved {{if .project}}AND project = '{{.project}}'{{end}} AND status = 'To Do'
  open: |
    resolution = unresolved {{if .project}}AND project = '{{.project}}'{{end}} AND status = 'Open'

They can be templates and can use command line options and configs to populate:

$ jira ls --named-query todo
+----------------+---------------+--------------+--------------+------------+--------------+--------------+
| Issue          | Summary       | Priority     | Status       | Age        | Reporter     | Assignee     |
+----------------+---------------+--------------+--------------+------------+--------------+--------------+
| TASK-258       | summary       | Medium       | To Do        | an hour    | gojira       | gojira       |
| SCRUM-267      | summary       | Medium       | To Do        | an hour    | gojira       | gojira       |
| PROJECT-252    | summary       | Medium       | To Do        | an hour    | gojira       | gojira       |
| BASIC-450      | summary       | Medium       | To Do        | an hour    | gojira       | gojira       |
+----------------+---------------+--------------+--------------+------------+--------------+--------------+
$ jira ls -n todo -p BASIC
+----------------+---------------+--------------+--------------+------------+--------------+--------------+
| Issue          | Summary       | Priority     | Status       | Age        | Reporter     | Assignee     |
+----------------+---------------+--------------+--------------+------------+--------------+--------------+
| BASIC-450      | summary       | Medium       | To Do        | an hour    | gojira       | gojira       |
+----------------+---------------+--------------+--------------+------------+--------------+--------------+

@coryb
Copy link
Contributor

coryb commented Sep 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants