pcondreicsik / jira-discord-google-script

Instructions for setting up a free basic jira to discord webhook using google scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jira to Discord Notifications

These are instructions for setting up a discord bot that posts changes to a specific jira board as messages to a discord channel. I am using google scripts for formatting. It's free, and relatevly easy to setup.

Why do we need this?

Jira sends data to discord, but discord can't handle the formatting, so it cannot read it. We need a transformation function in the middle.

The process is pretty easy: Every time something changes to our jira board, jira sends information to our google web app. Here we receive the data and format it in such a way that discord can digest it. Then, via the google web app, we forward it to discord.

We will need to work backwards to implements it.

Discord part

  1. Create a webhook for the channel you want the bot to post
  • Open the Server Settings and select the Webhook tab

Discord Webhook Tag

  • Click the button to create a new webhook

alt text

  • Customize your Discord Webhook
    • Edit the avatar : Click on the image next to the Webhook name.
    • Name your Webhook : It's helpful to give it a distinct name so you know what the bot does.
    • Choose in which channel the Webhook will post : The bot will post the updates in this channel.
  1. Copy the Webhook URL

We will need this one later. Don't worry, you can open the Webhook anytime to copy the link.

Google Script part

  1. Create a script

You will need to have a google account for this.

Create new Project

  1. Add the code to the script

For this just Copy/Paste code from the file jiraDiscordScript.js. I also added comments to pretty much every line of code.

Leave the name of the fuction to doPost(request). This is the method that google chose to run when someone sends a POST request to the webapp. Keep your Discord Webhook URL secret. Anyone with the URL can spam your channel. Feel free to make changes as you see fir the the message. I kept it simple, so I can explain exactly what I'm doing in every step.

  1. Publish the web app

Click on Publish -> Deploy as web app

Create new Project

  • Customize your Google Web App
    • Current web app URL : This is the URL that we will provide Jira. Keep it secret.
    • Project version : You need to set this up every time you deploy new changes. If you don't change the version, your changes will not take effect
    • Who has access to the app : I put Anyone, even anonymous. This way I don't need to link my Jira with google.

Every time you make a change to the script, and you want to test it, you will need to deploy it again. Just change the version number each time.

Jira part

  1. Log in to your jira dashboard
  2. Go to Setting and System
  3. Select Webhooks
  4. Click on Create a Webhook

Create new Jira Webhook

  1. Configure the Webhook

Configure Jira Webhook

  • Customize your Jira Webhook
    • Name : Give it a name to easily recognize what the Webhook does.
    • Status : Enable the Webhook.
    • URL : Add the URL from google web app here. It's important that you keep this a secret.
    • Events : Check all the events that should be delivered in the payload. I added quite alot, even though I am not using most of them.
    • Exclude body : This is important so we send a JSON to our google web app.
    • Save : Always save your work.

Test the whole thing

Create a new story. If everything went well, you should see the a new message in your Discord channel in a matter of seconds.

Conclusion

A recap of the steps we took:

  • Create a Discord Webhook
  • Create a Google Web App via Google App Scripts
  • Create a Jira Webhook

About

Instructions for setting up a free basic jira to discord webhook using google scripts

License:MIT License


Languages

Language:JavaScript 100.0%