Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jira support #637

Closed
dennis-f opened this issue Aug 31, 2015 · 62 comments
Closed

Jira support #637

dennis-f opened this issue Aug 31, 2015 · 62 comments
Assignees

Comments

@dennis-f
Copy link

i'd love to see Atlassin Jira integration

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@nwsheppard
Copy link

+1

@Sing-Li
Copy link
Member

Sing-Li commented Aug 31, 2015

@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.

@nwsheppard
Copy link

@Sing-Li - How is the Rocket.Chat Chat Ops Edition different from the hubot-rocketchat integration?

@Sing-Li
Copy link
Member

Sing-Li commented Aug 31, 2015

@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.

@nwsheppard
Copy link

@Sing-Li - Thanks.

@gabriellezbautista
Copy link

Raised hand (for someone who knows JIRA)

@marceloschmidt
Copy link
Member

Awesome! @gabriellezbautista would you be interested in checking out Rocket.Chat.Ops and do for JIRA something like we did for GitHub?

@gabriellezbautista
Copy link

I'm looking at it right now 👍 I'll try to put some time to it.

@gabriellebautista
Copy link

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.

@marceloschmidt marceloschmidt added this to the Roadmap milestone Sep 21, 2015
@Againstreality
Copy link

Anything new on this Topic?

@Againstreality
Copy link

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.

@chkal
Copy link

chkal commented Feb 10, 2016

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)

@rodrigok rodrigok modified the milestones: Roadmap, Important Feb 23, 2016
@knvpk
Copy link

knvpk commented Feb 25, 2016

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.

@chkal
Copy link

chkal commented Feb 25, 2016

@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?

@knvpk
Copy link

knvpk commented Feb 25, 2016

@chkal , yes you are right. hubot is not usefull in this scenario.

@chkal
Copy link

chkal commented Feb 25, 2016

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.

@Sing-Li
Copy link
Member

Sing-Li commented Feb 25, 2016

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 .

@engelgabriel
Copy link
Member

Depends on #2426

@thabbs
Copy link

thabbs commented Mar 8, 2016

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.

@engelgabriel
Copy link
Member

@Againstreality
Copy link

has anybody a working script?

@Againstreality
Copy link

anything new on this Topic?

@manuelbachl
Copy link

not yet, but maybe this weekend I'll dive into this. I'll keep you updated

@Angl0r
Copy link

Angl0r commented Apr 18, 2016

I hope this topic is still activ, i loved to see jira integration in Rocket.Chat

@manuelbachl
Copy link

It is, just need to renew JIRA plan, then I'm getting back on this

@AirCombat
Copy link

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

@lkraider
Copy link

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]
      }
    };
  }
}

@Angl0r
Copy link

Angl0r commented Apr 22, 2016

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

@manuelbachl
Copy link

@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?

@Angl0r
Copy link

Angl0r commented Apr 22, 2016

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:

  1. user_login -> I changed it to 'JiraBot'
  2. avatar_url -> I changed it to 'some_url_of_a_pic'

Notice that the Name and the Url must be written in apostrophe (' ')

With these changes the Webhook bot has a diffrent name and avatar :)

@konsumate
Copy link
Contributor

Make sure to include version/feature compatibility checks

@Againstreality
Copy link

The Script from @lkraider together with the mdoifikation from @Angl0r work fine for a start-

@lkraider
Copy link

@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.

@lkraider
Copy link

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.

@lkraider
Copy link

lkraider commented Apr 25, 2016

@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.

@davison
Copy link

davison commented Apr 26, 2016

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

@lkraider
Copy link

lkraider commented Apr 26, 2016

@manuelbachl
Copy link

yes, those integrations mentioned by @lkraider are just examples. But those are quite easy to expand to full functionality if the payloads are documented good enough. We switched from Jira and Bitbucket to Gitlab a few days agow and also want to have the full integration. So if no1 is faster than us, Gitlab will be the next Integration right after completing JIRA which is already in progress ;-)

@davison
Copy link

davison commented Apr 26, 2016

strange, I simplified the script down to a hardcoded returned content block and still got the same error, then it suddenly started working, then after re-instating the original script it worked. Do scripts get cached quite aggressively maybe? Whatever, it seems to be OK for now, so thanks for the efforts on this - looks like it will be really useful for us. :)

@gustavkarlsson
Copy link

gustavkarlsson commented Aug 20, 2016

If anyone's interested, I've created a JIRA integration that responds with a summary of a JIRA issue whenever it's mentioned.
You can configure some stuff such as what fields should be posted and there's an "extended" mode that shows more details if you append + to the issue.

Feel free to try it out and provide any feedback/help you can.
https://github.com/gustavkarlsson/rocketchat-jira-trigger

@antgel
Copy link
Contributor

antgel commented Sep 18, 2016

@gustavkarlsson Do you intend to extend this integration to incoming i.e. connecting a given JIRA project to a RocketChat room?

Also a question for everyone involved, is there a desire to get this integrated in some way, or do we think we'll all be rolling our own for the foreseeable future? :)

@gustavkarlsson
Copy link

@antgel No plans for that. This is for outgoing messages only.

@jhmk
Copy link

jhmk commented Oct 7, 2016

Due the Snap installation will create a read-only directory the Jira Webhook script runs into problems. Not sure if this also causes some problems with other Integrations.

https://github.com/malko/rocketchat-jira-hook/issues/1

@Rohlik
Copy link
Contributor

Rohlik commented Jan 26, 2017

I found this integration Rocket.chat -> Jira - https://hub.docker.com/r/gustavkarlsson/rocketchat-jira-trigger/ based on Java. It is use Outgoing webhook.

Or you can try this integration Jira -> Rocket.chat - https://blog.zemna.net/web/how-to-integrate-jira-and-bitbucket-application-with-rocket-chat/ based on Incoming webhook.

@btstream
Copy link

Or you can try this integration Jira -> Rocket.chat - https://blog.zemna.net/web/how-to-integrate-jira-and-bitbucket-application-with-rocket-chat/ based on Incoming webhook.

I tried, jira received a 400 response...

@JSzaszvari
Copy link
Contributor

JSzaszvari commented Jun 19, 2017

Sorry not sure what the status of this is, but just going to quickly pop some stuff here.

There isnt any work as far as i am aware that needs to be done on this.

The current integration script utilising the incoming webhooks with JIRA posting to it work perfect and can be customised to your liking. This is what our 'helpdesk feed' looks like in Rocket.Chat:

screen shot 2017-06-19 at 4 45 30 pm

The incoming intergration is done with this gist here

https://gist.github.com/malko/7b46696aa92d07736cc8ea9ed4041c68

To interact with JIRA you can use some great hubot plugins that are around

https://www.npmjs.com/search?q=hubot+jira

This can be done with the internal/built in Rocket.Chat hubot or your own instance.

This is the one I use https://www.npmjs.com/package/hubot-jira-bot

We use it to 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.

@timkinnane
Copy link
Contributor

@JSzaszvari I'd like to close this as I've been doing with other bot suggestions and you've done to a few too, because they're out of scope. But this one seems to have a lot of history. If you think it's OK to handle from here as part of the collection of proposals for discussion / voting under #10174, please go ahead and close.

@JSzaszvari
Copy link
Contributor

JSzaszvari commented Mar 20, 2018

@rocket-cat close

@timkinnane 100% agree. This is already handled with incoming integrations, existing Hubot functionality and when released Rocket.Chat Apps will allow a much more intergrated if needed.

I'm saying that, I'll now close this issue.

@rocket-cat rocket-cat bot closed this as completed Mar 20, 2018
@theorenck theorenck removed this from the Mid-term milestone Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests