Closed dennis-f closed 6 years ago
+1
@dennis-f , @nwsheppard - There is no Jira expertise in the current team. Can you please see if any Jira community members may be able to help out? There is no need to understand the Rocket.Chat code, they just need to contribute a 'hubot' adapter over in the Rocket.Chat Chat Ops Edition project. Thanks.
@Sing-Li - How is the Rocket.Chat Chat Ops Edition different from the hubot-rocketchat integration?
@nwsheppard It is 100% hubot / hubot-rocketchat powered! It will have ALL the features of the core Rocket.Chat plus it will have some dedicated user interface that is specific to the bot(s) that is(are) integrated. Essentially turning a chat into a chat-app. And it will be, by design, massively scalable. BTW ... it is post 1.0 - just starting up there.
Before that is ready, the very same hubot that you create will be compatible - and can be used - with the current core Rocket.Chat.
@Sing-Li - Thanks.
Raised hand (for someone who knows JIRA)
Awesome! @gabriellezbautista would you be interested in checking out Rocket.Chat.Ops and do for JIRA something like we did for GitHub?
I'm looking at it right now :+1: I'll try to put some time to it.
Upon searching npm registry, I found this https://github.com/ndaversa/hubot-jira-bot. Maybe we can hookup with the developer and see if we can re-use it.
Anything new on this Topic?
Maybe the easiest way would be to use the Jira Webhooks (https://developer.atlassian.com/jiradev/jira-apis/webhooks) and make a Mapper from Jira Json to RC Json.
I also think that using the native JIRA WebHooks may be a good option. The only thing missing here is some way to translate application specific hook payloads (JIRA in this case) into something Rocket.Chat understands. I could imagine that if there is some API support for such transformations in Rocket.Chat, adding integrations for all kind of services would be easy (see #638 and others)
Rather than providing API by rocket chat or JIRA to transform data, i think it is nice to have hubot script that will transform the data from any source lets say gitlab or jira to a format that is understand by the Rocket chat.
@pavankumarkatakam Sure, that would work. But it looks like the rocketchat hubot doesn't provide the full feature set of the web hooks. Especially it doesn't allow to change the display name and the avatar for individual integrations. Or am I missing something here?
@chkal , yes you are right. hubot is not usefull in this scenario.
So I wonder what the primary way of integrating which 3rd party application should be in the long run.
Of cause hubot will work in most cases (and with existing hubot plugins + the hubot-rocketchat) adapter. But I think this way of integrating doesn't allow the level of flexibility that users want. Like having different avatars/usernames for each system which is integrated. That's something that Slack brings out of the box.
Actually, that has very little to do with the means of integration.
There has been talks on giving "system bot users" privilege to create new 'powerless' alien-system users (complete with avatar), and once that's in place - what you mentioned will be possible.
The very same 'feature' is needed in many other scenarios - including better federation support.
Didn't look like there is an existing issue - added #2349 .
Depends on #2426
Please, the Jira web hook is a really perfect starting point. You just have to parse the JSON which rocketchat is receiving from the hook. That's all.
Please see initial documentation at https://github.com/RocketChat/Rocket.Chat/wiki/WebHook-Scripting---GitHub
has anybody a working script?
gonna work on it after finishing BitBucket script
@manuelbachl let me know if you have a working repo, would like to contribute to this one
@denen99, I haven't started this yet. Have some trouble getting my hook working for Bitbucket. Once this problem is solved, I'll finish the BitBucket integration. I Think much code of this integration can be reused for JIRA. But I'll let you know once I'm starting ;-)
What problem are you having @manuelbachl ?
the probelm is, that I can't receive the payload from Bitbucket. Have been working on this with @rodrigok an this last friday. But we should meet again in chat for fixing this. Using the same hook, rodrigok reveived the payload. It seems, that there is any issue with our R.C setup. I'm at home in about 1 and a half hour - maybe he's in then, so we could move on working on the integrations ;-)
@rodrigok will be here in the office in 1 hour too. Let's get that fixed.
thanks to @rodrigok our hook works for now. I'll do the integration tomorrow and will paste the link to the repo here
Should there be a "webhooks" repo under RocketChat org where we can keep all the contributed webhooks ?
there are plans for building a "marketplace" - as website and even inApp, but it's a little bit too early to talk about further details :-D But be sure, you'll all be informed as soon as it's working ;-) Since then, have a look at the Wiki https://github.com/RocketChat/Rocket.Chat/wiki#technical-guides - there some integrations will be mentioned
We are trying to create our first MarketPlace version this week
@denen99 I've got the Bitbucket Server integration up and running. But I've recognized just at this moment, that there is only a possibility to receive updates on repositories. The POST receive webhooks from bitbucket server just send on receiving pushes. As far as I could figure out, there is an other behavior for Bitbucket Cloud, there you could also receive pull requests a.s.o...
Because of this, I'll split up the integration and will buld two different Scripts:
last one is quite done for now. If we want to receive more messages, I would need help on building an Bitbucket Server Plugin which provides a pull request webhook (and maybe others). I've no idea on how to create Atlassian Plugins, so I would love to see any contributors building the needed webhook.
https://confluence.atlassian.com/bitbucketserver/draft-using-repository-hooks-776639841.html down at the bottom, there is an interesting part...
I'm not sure, wether this could be the solution: https://developer.atlassian.com/bitbucket/server/docs/latest/how-tos/repo-hook-examples/async-post-receive-config.html
thanks @manuelbachl i thought we were talking about JIRA, not BitBucket though ?
yes @denen99 you're totally right, but as stated before, I just wanted to finish the BB integration because I've already been working on this when I found this issue.
anything new on this Topic?
not yet, but maybe this weekend I'll dive into this. I'll keep you updated
I hope this topic is still activ, i loved to see jira integration in Rocket.Chat
It is, just need to renew JIRA plan, then I'm getting back on this
This would be a major selling point in convincing the rest of the team to go for rolling this out to the rest of the company
Here's a script I created to parse the Jira webhook JSON in a manner similar to what the Slack integration service does:
class Script {
process_incoming_request({ request }) {
if (!(request["content"] && request.content["webhookEvent"])) {
return {
error: {
success: false,
message: 'Unsupported request'
}
};
}
const ref_url = request.content.issue.self;
const url_parts = /^(\w+\:\/\/)?([^\/]+)(.*)$/.exec(ref_url);
const url_origin = url_parts[1] + url_parts[2];
const user_login = request.content.user.name;
const user_name = request.content.user.displayName;
const avatar_url = request.content.user.avatarUrls["16x16"];
const issue_type = request.content.issue.fields.issuetype.name;
const issue_icon = request.content.issue.fields.issuetype.iconUrl;
const issue_number = request.content.issue.key;
const issue_title = request.content.issue.fields.summary;
const issue_url = url_origin + '/browse/' + issue_number;
const issue_link = '[' + issue_number + '](' + issue_url + ')';
let text = user_name;
let emoji = '';
switch (request.content.webhookEvent) {
case 'jira:issue_created':
emoji = ':triangular_flag_on_post: ';
text += ' created ' + issue_type + ' ' + issue_link;
break;
case 'jira:issue_updated':
emoji = '';
text += ' changed ' + issue_type + ' ' + issue_link;
const actions = {
'jira:resolution': function(item, items) {
emoji = item.to === null ? ':triangular_flag_on_post: ' : ':white_check_mark: ';
item = items['jira:status'];
return ' from "' + item.fromString + '" to "' + item.toString + '"';
}
}
let items = request.content.changelog.items;
let actions_items = {};
for (let i = 0; i < items.length; ++i) {
let item = items[i];
let action = item.fieldtype + ':' + item.field;
actions_items[action] = item;
}
let result;
for (let action in actions_items) {
let item = actions_items[action];
if (actions[action]) {
result = actions[action](item, actions_items);
text += result;
break;
}
}
if (result === undefined) {
return {
error: {
success: false,
message: 'Unsupported action'
}
};
}
break;
default:
return {
error: {
success: false,
message: 'Unsupported event'
}
};
}
const attachment = {
author_icon: issue_icon,
author_name: issue_title,
author_link: issue_url,
fields: []
};
if (request.content.issue.fields.assignee) {
attachment.fields.push({
title: 'Assignee',
value: request.content.issue.fields.assignee.displayName,
short: true
});
}
if (request.content.issue.fields.creator) {
attachment.fields.push({
title: 'Creator',
value: request.content.issue.fields.creator.displayName,
short: true
});
}
// attachment.fields.push({
// title: 'Request',
// value: JSON.stringify(request.content),
// short: false
// });
return {
content: {
icon_url: avatar_url,
alias: user_login,
text: emoji + text,
attachments: [attachment]
}
};
}
}
This Script Works fine!!! But it seems that Rocket.Chat ignores the Alias and the avatar of the bot. It keeps posting it under my credentials. Thank you for this nice script
@lkraider is this script parsing all possible payloads from JIRA? In other words, is it complete? If not, I'll start working on this intergration on monday, may I use your Script as a base?
After a littlebit of Scripting i finaly managed to overwrite the credentials under wich the bot posts your Jira Tickets. You need to modify the following entrys:
Notice that the Name and the Url must be written in apostrophe (' ')
With these changes the Webhook bot has a diffrent name and avatar :)
Make sure to include version/feature compatibility checks
The Script from @lkraider together with the mdoifikation from @Angl0r work fine for a start-
@manuelbachl The script is a start, I tried to replicate what Slack provides for Jira Issue updates. This could definitely be expanded to have all types of events handled and maybe have some form of configuration options.
Here are some anonymized Jira webhook JSON data so people can identify other fields to extract: https://gist.github.com/lkraider/c0eccf6677ce5372e5528dba7274763d
They are the output for issue updates only, including Resolved, Reopened, Worklog and Assignee change.
@Angl0r You can remove icon_url
and alias
from the content
, like this:
return {
content: {
text: emoji + text,
attachments: [attachment]
}
};
This will make the message use the Bot details configured in the Rocket integration webhook settings.
with the script above (including lkraider's modification to the return content) I get the following error in the chat server logs:
20160426-14:11:57.612(1) rocketchat_integrations api.coffee:165 Integrations ➔ Incoming WebHook.error function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Script = (function () { function Script() { _classCallCheck(this, Script); } Script.prototype.process_incoming_request = function process_incoming_request(_ref) { ...
There are no docs (that I can find) explaining how scripts are supposed to work.. has something changed in a recent version perhaps? I'm using 0.27
i'd love to see Atlassin Jira integration
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.