ndaversa / hubot-jira-bot

Lets you search for JIRA tickets, open them, transition them thru different states, comment on them, rank them up or down, start or stop watching them or change who is assigned to a ticket. Also, notifications for assignments, mentions and watched tickets.
https://www.npmjs.com/package/hubot-jira-bot
MIT License
61 stars 43 forks source link

Issue with assigning and transition tickets using the slack adapter #14

Closed danqa closed 7 years ago

danqa commented 8 years ago

Hi there.

I am trying to assign and transition a ticket via slack using this hubot plugin. I can create the ticket without issue. However when I do either:

<ticket-number> assign <Username>
or 
<ticket-number> to resolve 

The bot does not return with any response in slack and the ticket is not updated. I see no errors in the logs so I am not sure why its not working. And help/debugging guidance would be greatly appreciated.

ndaversa commented 8 years ago

@danqa currently jirabot relies on the user on slack's email address to match their jira email address.

Without that it can't really do the user lookup required for some of those actions

If thats already true for you I would need to dig in deeper to understand why its not working

danqa commented 8 years ago

@ndaversa Thanks for the quick response. Just verified that the email for my slack and JIRA accounts are the same. Hubot has its own JIRA account to create ticket (as it needs certain permissions). Might that be the reason?

ndaversa commented 8 years ago

@danqa No that should be fine, I have the same setup in my deployment.

However, its possible the user that your bot is using to perform the actions doesn't have permission to do the actions you want.

Check the JIRA permission helper, and/or login as that bots account and try performing the actions desired.

danqa commented 8 years ago

@ndaversa Will do. I'll let you know. Thanks.

danqa commented 8 years ago

@ndaversa So I went to JIRA, became the hubot user and was able to assign and transition the tickets I created from slack in the Jira UI with that user. Anything else I should try.

danqa commented 8 years ago

@ndaversa would it be possible for you to add a response message to slack when an action fails (some error message using what the api from jira returned) so I could debug this?

ndaversa commented 8 years ago

@danqa generally I do log api failures. The only other thing that could be wrong is a missing ENVVAR for the state types and transitions

danqa commented 8 years ago

@ndaversa hmm. So I have this set for transitions:

HUBOT_JIRA_TRANSITIONS_MAP=[{"name":"open","jira":"Open"},{"name":"start", "jira":"Start Dev"},{"name":"resolve","jira":"Resolve"}]

There are more so do I need to add all of them (as these are the only ones I want)?

For types I have

HUBOT_JIRA_TYPES_MAP={"bug":"Bug", "task": "Task"}

Are these what you mean and do they look incorrect?

Sincerely,

ndaversa commented 8 years ago

Yea I was referring to HUBOT_JIRA_TRANSITIONS_MAP

Assuming those names match exactly to the Transitions you have in JIRA it should work. However you need to check it matches to a state in JIRA as an example here is ours @Wattpad:

[ {
  "name": "triage",
  "jira": "Triage"
}, {
  "name": "icebox",
  "jira": "Icebox"
}, {
  "name": "backlog",
  "jira": "Backlog"
}, {
  "name": "devready",
  "jira": "Selected for Development"
}, {
  "name": "inprogress",
  "jira": "In Progress"
}, {
  "name": "design",
  "jira": "Design Triage"
}, {
  "name": "running",
  "jira": "Running"
}, {
  "name": "review",
  "jira": "In Review"
}, {
  "name": "done",
  "jira": "Done"
} ]
danqa commented 8 years ago

@ndaversa so we have a transition for example called Resolve and a state called Resolved. Do those need to be the same for this to work?

ndaversa commented 8 years ago

@danqa no they don't need to be, but if you look thru some of the transition code you can get a sense of how it tries to transition from one state to another.

At this point might be worth trying a debug statement or two to see whats broken on your end, hard for me to tell from afar.

If you track down a problem I would be happy to help or accept a pull request for a fix ! ;)

danqa commented 8 years ago

@ndaversa sounds good. Thanks

danqa commented 8 years ago

Hi @ndaversa

I have finally had some time to try and debug the issues I was having with doing things like adding comments or transitioning issues. I have had no luck. I can create bugs/tasks, I can looks up tickets. But when I try to transitions it just wont work. Here is some log output:

[Mon Jun 13 2016 15:41:55 GMT-0400 (EDT)] DEBUG Received message: 'jira help' in channel: ds, from: ds [Mon Jun 13 2016 15:41:55 GMT-0400 (EDT)] DEBUG Message '007 jira help' matched regex //^\s*[@]?007[:,]?\s*(?:(?:help jira|jira help)(?: (.*))?)//; listener.options = { id: null } [Mon Jun 13 2016 15:41:55 GMT-0400 (EDT)] DEBUG Executing listener callback for Message '007 jira help' [Mon Jun 13 2016 15:42:22 GMT-0400 (EDT)] DEBUG Received message: 'dev-1678 < comment' in channel: ds, from: ds [Mon Jun 13 2016 15:42:22 GMT-0400 (EDT)] DEBUG Executing listener callback for Message '007 dev-1678 < comment' [Mon Jun 13 2016 15:42:22 GMT-0400 (EDT)] DEBUG Fetching: https://<redacated>.atlassian.net/rest/api/2/issue/DEV-1678?expand=transitions&fields=issuetype%2Cstatus%2Cassignee%2Creporter%2Csummary%2Cdescription%2Clabels%2Cproject [Mon Jun 13 2016 15:42:23 GMT-0400 (EDT)] DEBUG Fetching: https://<redacated>.atlassian.net/rest/api/2/issue/DEV-1678/watchers [Mon Jun 13 2016 15:42:23 GMT-0400 (EDT)] DEBUG Supressing ticket attachment for DEV-1678 in ds [Mon Jun 13 2016 15:43:52 GMT-0400 (EDT)] DEBUG Received message: 'dev-1678 to resolve' in channel: ds, from: ds [Mon Jun 13 2016 15:43:52 GMT-0400 (EDT)] DEBUG Executing listener callback for Message '007 dev-1678 to resolve' [Mon Jun 13 2016 15:43:52 GMT-0400 (EDT)] DEBUG Fetching: https://<redacated>.atlassian.net/rest/api/2/issue/DEV-1678?expand=transitions&fields=issuetype%2Cstatus%2Cassignee%2Creporter%2Csummary%2Cdescription%2Clabels%2Cproject [Mon Jun 13 2016 15:43:53 GMT-0400 (EDT)] DEBUG Fetching: https://<redacated>.atlassian.net/rest/api/2/issue/DEV-1678/watchers [Mon Jun 13 2016 15:43:53 GMT-0400 (EDT)] DEBUG Supressing ticket attachment for DEV-1678 in ds

The only thing that I see is that when I can jira help I get response that the call matched a regex. I don't get that for the comment or transition calls. I also don't see any error being returned.I have added console.log debugging and see nothing that seems wrong. If you have any ideas let me know. Thanks in advance.

ndaversa commented 7 years ago

@danqa I have upgraded to use the latest hubot-slack adapter. See if thinks work for you now

kunickiaj commented 7 years ago

FWIW, I'm having the exact same trouble as @danqa

ndaversa commented 7 years ago

@kunickiaj are you running the latest hubot-slack adapter?

kunickiaj commented 7 years ago

Ended up getting it working by changing some of the configured transitions. Perhaps I can contribute some explanations to the docs. One thing that does not work for me are most features via DM. For example, transitions and comments do not work via DM. Is this intentional? I would rather not clutter a public channel with some of that. Also was going to look into adding support for parameters when transitioning e.g. Resolution when transitioning to Resolved. 

On Thu, Jan 19, 2017 at 7:21 AM -0800, "ndaversa" notifications@github.com wrote:

@kunickiaj are you running the latest hubot-slack adapter?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ndaversa commented 7 years ago

@kunickiaj its not intentionally disabled for DMs but might be an artifact of how its implemented.

Happy to take any PRs for documentation or fixes on the matter.

rholloway commented 7 years ago

@kunickiaj what were the configured transition changes you had to make? We have the same problems as you. Can create tickets and search them, but cannot assign and do some other tasks. I thought I had transitions set up correctly (it doesn't complain and shows them in help at least)