Mattermost, Inc.

[SOLVED] Mattermost Jira integragrion doesn't parse the JSON from Jira correctly

Hello Everyone

I am using the Mattermost Jira integration with my Jira. The Webhooks are working fine and my Mattermost receives the JSONs from Jira. But it seems that Mattermost ignores the context path, that I have configured in my Jira URL. The links in the messages in Mattermost are always wrong because Mattermost ignores the context path from my URL.

I verified the JSON that Mattermost gets from Jira with tcpdump on the Mattermost server and I see that all URLs are correct. So I think that the error must come from Mattermost.

Thank you for your help

Hi @Toni,

Thank you for your feedback,

Not sure whether this doc is helpful?

You can also try upgrading to the latest version of Mattermost if you haven’t already.

Let us know if this helps and we can troubleshoot further.

Hi @lindy65

Thank you for your answer.

I used your doc to configure Mattermost and Jira and technically everything works fine. Mattermost receives the JSON from Jira (with the right URLs) and the message gets posted in my channel. It’s just the link in the message that is wrong.

Example: Mattermost gets from Jira the URL https://<company name>.<tld>/jira/browse/CHGLG-9292 but the link in the messages shows to https://<company name>.<tld>/browse/CHGLG-9292. “jira” from my URL is the context path that I have configured in my Jira I don’t know if maybe this is the problem that my Jira has a context path.

Yes I have already the latest version of Mattermost.

Hi Toni, is it possible for you to post a sample of the JSON object that you’re receiving from JIRA? I’d like to play with it in a debugger and try to understand why it’s being incorrectly parsed. If you don’t feel comfortable posting the JSON here, let me know, and I’ll let you know how to send it to us privately.

Hi @MusikPolice

Yes I prefer to send the JSON in private.

Hey @Toni,

I figured out the problem. Our JIRA plugin does indeed assume that your ticket is located at https://<company name>.<tld>/browse/CHGLG-9292 rather than https://<company name>.<tld>/jira/browse/CHGLG-9292.

This line of the code figures out the JIRA server’s URL by stripping the domain name and TLD out of the issue.self field of the JSON object, and this line appends the /browse/issue.key to that domain to form the URL of the JIRA ticket. It doesn’t know that you’ve put your Jira instance at https://<company name>.<tld>/jira/..., so it builds the wrong URL.

The advantage to our current approach is that it “automatically” adapts to link back to whichever JIRA server sent the webhook. The only way to “fix” this for you would be to allow you to configure the URL of your JIRA server. I’m not sure if this would negatively impact other users who might have internal and external JIRA urls that need to be accounted for.

Hi @MusikPolice

So you are telling me that this is not going to be fixed in Mattermost? I think this would be a little bit strange because I’m for sure not the only one that has configured a context path in the URL from Jira. And if you write a Jira Plugin then you must consider that this configuration is possible and must can handle it. It can’t be that Mattermost tells the people how their URLs has to look like only so the Jira Plugin can do his work properly. Do you know what I mean?

That’s not at all what I said. I acknowledged that there is a problem, and we’re now trying to figure out if there’s a good way to solve it without impacting other customers whose configurations are different from yours. There’s a discussion about this issue going on in our pre-release chat. You’re welcome to weigh in.

Hey @Toni, we created a ticket here:

We should be able to fix this on our end by reading the JIRA URL

Hey @jasonblais

I updated Mattermost right now and the Jira integration works fine now.

Thanks to you and your team for the great job :slight_smile:


Good to hear @Toni

Thanks for posting back to let us know :slight_smile: