Skip to content

Commit

Permalink
Changed the regex to be a string that we convert to regexp. Removed d…
Browse files Browse the repository at this point in the history
…efault values from Dockerfile
  • Loading branch information
shaunburdick committed Feb 3, 2016
1 parent 4885e6f commit 885a15f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ FROM node:latest
MAINTAINER Shaun Burdick <[email protected]>

ENV NODE_ENV=production \
JIRA_PROTOCOL=https \
JIRA_HOST=jira.yourdomain.com \
JIRA_PORT=443 \
JIRA_PROTOCOL= \
JIRA_HOST= \
JIRA_PORT= \
JIRA_BASE= \
JIRA_USER=username \
JIRA_PASS=password \
JIRA_API_VERSION=latest \
JIRA_VERBOSE=false \
JIRA_STRICT_SSL=false \
JIRA_REGEX=([A-Z]{1}[A-Z0-9]+\-[0-9]+) \
JIRA_USER= \
JIRA_PASS= \
JIRA_API_VERSION= \
JIRA_VERBOSE= \
JIRA_STRICT_SSL= \
JIRA_REGEX= \
JIRA_SPRINT_FIELD= \
SLACK_TOKEN=xoxb-foo \
SLACK_AUTO_RECONNECT=true
SLACK_TOKEN= \
SLACK_AUTO_RECONNECT=

ADD . /usr/src/myapp

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The config file should be filled out as follows:
- apiVersion: string, API version slug, usually latest
- verbose: boolean, Verbose logging
- strictSSL: boolean, set false for self-signed certificates
- regex: string, a string that will be used as a RegExp to match tickets, defaults to '([A-Z][A-Z0-9]+\-[0-9]+)'
- sprintField: string, If using greenhopper, set the custom field that holds sprint information (customfield_1xxxx)
- customFields:
- Add any custom fields you would like to display
Expand Down
6 changes: 4 additions & 2 deletions config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const config = {
apiVersion: 'latest',
verbose: false,
strictSSL: false,
regex: /([A-Z]{1}[A-Z0-9]+\-[0-9]+)/g,
regex: '([A-Z][A-Z0-9]+\-[0-9]+)',
sprintField: '',
customFields: {},
customFields: {

},
},
slack: {
token: 'xoxb-Your-Token',
Expand Down
5 changes: 4 additions & 1 deletion lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Bot {

this.controller = Botkit.slackbot();

this.ticketRegExp = new RegExp(config.jira.regex, 'g');
logger.info(`Ticket Matching Regexp: ${this.ticketRegExp}`);

this.jira = new JiraApi(
config.jira.protocol,
config.jira.host,
Expand Down Expand Up @@ -210,7 +213,7 @@ class Bot {
return retVal;
}
const uniques = {};
const found = message.match(this.config.jira.regex);
const found = message.match(this.ticketRegExp);
const now = Date.now();
let ticketHash;
if (found && found.length) {
Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function parse(config) {
config.jira.apiVersion = process.env.JIRA_API_VERSION || config.jira.apiVersion;
config.jira.verbose = parseBool(process.env.JIRA_VERBOSE) || config.jira.verbose;
config.jira.strictSSL = parseBool(process.env.JIRA_STRICT_SSL) || config.jira.strictSSL;
config.jira.regex = process.env.JIRA_REGEX ? new RegExp(process.env.JIRA_REGEX, 'g') : config.jira.regex;
config.jira.regex = process.env.JIRA_REGEX || config.jira.regex;
config.jira.sprintField = process.env.JIRA_SPRINT_FIELD || config.jira.sprintField;

config.slack.token = process.env.SLACK_TOKEN || config.slack.token;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slack-jirabot",
"version": "2.0.1",
"version": "2.0.3",
"description": "Slackbot for interacting with JIRA",
"main": "app.js",
"private": true,
Expand All @@ -10,7 +10,7 @@
"unit": "faucet",
"lint": "eslint .",
"coverage": "istanbul cover --include-all-sources tape test/*.test.js",
"coveralls": "cat ./coverage/lcov.info | coveralls --verbose",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"travis": "npm run coverage && npm run coveralls"
},
"author": "Shaun Burdick <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion test/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test('Config: use env values over file values', (assert) => {
process.env.JIRA_REGEX = 'foo';
const conf = Config.parse(rawConfig);

assert.deepEqual(conf.jira.regex, /foo/g);
assert.deepEqual(conf.jira.regex, 'foo');
assert.end();
});

Expand Down

0 comments on commit 885a15f

Please sign in to comment.