Connects Hubot with Jira
JavaScript HTML
Switch branches/tags
Clone or download
Emil Öberg
Emil Öberg 1.2.0 Release
* As the Handlebars template is used to create a JSON (which is sent to Slack), there's now the Handlebars helper `safe` which will escape `"` and `\`. If you've customized the Handlebars template, please add the helper when printing variables. E.g. change `{{fields.summary}}` to `{{safe fields.summary}}`. Take a look at `changed-issues.hbs` for the default template.

* Tabs in Jira responses are removed
Latest commit 3e12ac6 Nov 2, 2015

README.md

hubot-jira-servant

Connects Hubot with Jira.

Made for Slack

Therefore you need to start Hubot with the Slack adapter to use this plugin. With some modifications it should work with other adapters as well.

Work in progress

This is very much a work in progress. Currently displaying changed issues (e.g. "what issues was changed yesterday?") is supported.

Screenshot

Screenshot

Commands:

Perfect for answering the question "What happend yesterday?"

  • hubot jira changed <project> - Get yesterdays changed Jira issues
  • hubot jira changed [days] <project> - Get Jira issues changed the passed [days] days.
  • hubot jira changed [date] [date] <project> - Get Jira issues changed the day between [date] and [date]
  • hubot jira changed [date] [days] <project> - Get Jira issues changed between [date] and [days] days before that.
  • hubot jira changed [date] <project> - Get Jira issues changed the day before [date]

If the project key <project> (e.g. ABC if you have a project named ABC in Jira) is omitted, the default project (set by the environment variable HUBOT_JIRA_DEFAULT_PROJECT) will be used instead.

[days] are numbers, e.g. 5 and [date] is a string (the correct way to print dates), e.g. 2015-03-29. You may also use j for short, e.g. hubot j changed.

Installation

In Hubot root folder, run:

npm install hubot-jira-servant --save

Then add hubot-jira-servant to your external-scripts.json:

[
  "hubot-jira-servant"
]

Start Hubot with these 4 environment variables:

HUBOT_JIRA_HOST=your-jira.atlassian.net # NOTE: No 'http://'
HUBOT_JIRA_USER=username
HUBOT_JIRA_PASS=password
HUBOT_JIRA_DEFAULT_PROJECT=ABC

Default project is the project key for your default project, usually a couple of letters before the issue number, e.g. ABC in ABC-123. If you don't give another project key in your command, e.g. jira changed DEF this is the key being used.

Optional configuration

Sometimes there are information in Jira which you aren't that interested in. If there are some actions (e.g. the assignee of an issue has been changed) which you don't want Hubot to show you, you may blacklist the actions by adding an environment variable:

export HUBOT_JIRA_ACTION_BLACKLIST="assignee|rank"

The above will make sure that assignee or rank changes never show. Note the quotation marks, " and the pipe, |, delimiting multiple entries. The "action" is the wording which goes before the arrow in the output message. In the screenshot above, the actions would be description, Request participants and status.

Development

This module is developed in EcmaScript 2015. All source files lives in /src and gets transpiled into /dist. Use provided gulp script (by running gulp in the root folder of the module) to start a watcher which automagically transpiles files when they're changed.

Change message output

To change the message output, you may modify the changed-issues.hbs file. This is a handlebars file.

  • To see what variables are available to you, check the provided sample json file in /docs.
    • All Swag Handlebars helpers may be used. E.g. {{uppercase fields.summary}}.
  • To get a list of all available Jira statuses (used to set the color of the message in the default message), go to: https://{your-account}.atlassian.net/rest/api/2/status
  • Read more about formatting Slack messages: https://api.slack.com/docs/formatting