gsingers / slack-jira-plugin

A Slack plugin that watches channels for messages about JIRA and acts accordingly
MIT License
252 stars 83 forks source link

Type `url` undefined #5

Closed timfallmk closed 8 years ago

timfallmk commented 9 years ago

I can get the bot to respond to issues in Slack, but it doesn't seem to get the correct base url to look up the issues. My config is:

ar slackbot = require('./lib/bot');

var config = {

  showIssueDetails: true,
  showDetailsByDefault: true,//if true, you don't need the '+' to get details
  bot_name: "Jira-Bot",//Provide the name to post under
  token: '<token>',
  jira_urls: {
    "MidoBugs": {
      url: "https://midobugs.atlassian.net/browse/",
      jira: {//OPTIONAL: provide access to jira credentials for a particular repository
        user: '<user>',
        password: '<password>',
        host: 'midobugs.atlassian.net',
        protocol: 'https',
        port: 443,
        version: '2',
        strictSSL: true
      }
    },
       "MidoNet": {url: "https://midonet.atlassian.net/browse/"}
  },
  search_cmd: "search",
  //Since search results can be verbose, you may not want to muddy the channel
  search_output_chan: "this",//if the value is "this", then the current channel will be used, else the name of a channel
  projects: ["MN", "MNA", "MNC", "MND", "MDI", "IT", "MC"],
  post: true,
  verbose: true,
  emoji: ":poop:",
  link_separator: ", "// use \n if you want new lines
};

//DO NOT EDIT BELOW HERE
var slackbot = new slackbot.Bot(config);
slackbot.run();

The output I get for a match is:

Creating API for:
MidoBugs
{ url: 'https://midobugs.atlassian.net/browse/',
  jira: 
   { user: '<user>',
     password: '<password>',
     host: 'midobugs.atlassian.net',
     protocol: 'https',
     port: 443,
     version: '2',
     strictSSL: true } }
Pattern is: (?:\W|^)((MN|MNA|MNC|MND|MDI|IT|MC)-\d+)(\+)?(?:(?=\W)|$)
Match:
{ reply_to: 1363,
  type: 'message',
  channel: 'C025Q3189',
  user: 'U025Q317Z',
  text: 'MNA-273',
  ts: '1429816608.000619' }
[ 'MNA-273',
  'MNA-273',
  'MNA',
  undefined,
  index: 0,
  input: 'MNA-273' ]
undefined

Also notice that it creates the api for only the first listed jira url.

tjdownes commented 9 years ago

You need a token for the Slack API: https://api.slack.com/web

timfallmk commented 9 years ago

Hi @tjdownes There is one, as you can see in the config. It is removed for security, and the user/pass combos are changed for the same reason. I'll make it more explicit.

tjdownes commented 9 years ago

Yup, you're right. Your error and mine were different. However, I just bumped into the same error, and it seems even though I had a named connection it was still expecting "DEFAULT". When I renamed the connection to DEFAULT, it works

Error handling leaves something to be desired, for sure.

timfallmk commented 9 years ago

Hmm, that is strange. I do seem to get one API connection built for the SSL-required Jira, but the "open" one doesn't show. Let me try switching that name to DEFAULT and see what I get.

tjdownes commented 9 years ago
jira_urls: {
        "DEFAULT": {
            url: 'https://myurl/browse/',
            jira: {//OPTIONAL: provide access to jira credentials for a particular repository
                user: 'user',
                password: 'Password',
                host: 'host.net',
                protocol: 'https',
                port: 443,
                version: '2',
                strictSSL: true
            }
        }
    },

This is what my jira_urls looks like now, and it is working

timfallmk commented 9 years ago

Yep, changing at least one of the JIRA links to DEFAULT gets it past that problem. Seems like a bug.

tjdownes commented 9 years ago

I agree. Bug.

gsingers commented 9 years ago

the way it works is given a project name, it looks for an entry in the jira_urls. If there isn't one there, it falls back on DEFAULT.