JIRA workflow Automation
Most of the time Developers would be busy in implementation and they always tend to forget updating the JIRA status which results in multiple reminders from Manger/Lead. For few, the flow looks to be complicated and tricky, hence not everyone knows the proper state a JIRA is to be updated to.
The above two reasons forced me to come up with a way which would solve both the problems and that is when I thought of Automating the complete JIRA flow. With this in place, no one should be bothered about updating the JIRA status instead JIRA needs to interpret few parameters and update the status by itself.
Does it sound feasible ? doable ?
This is exactly the doubt I had in my mind when I started. I started scribbling my head on implementing this and did some research but could not find much of information . Then my manager showed me a way on how we could achieve it using Webhooks and Lambda, that is how the story started and now I can proudly say that I have successfully automated the complete JIRA flow.
A high level overview on this could be found here.
Okay, So I hope you guys have got some idea on how actually we are going to achieve this ? Lets get started
What all you need?
- Visual studio
- Node js
- Account in Amazon web services
- Github Account [Admin access]
So the basic mantra behind this is simple.
We are going to create a webhook using API gateway and link that with the Github repository and interpret the JSON payload using lambda.
What role does WEBHOOK play?
Webhook will read each and every event that has been triggered from github repository with the data published in JSON format.
It always acts as a bridge between two components.
Where does AWS fit in the picture?
Even before we get into that, we need to understand what AWS API Gateways are and how do we create them.
Putting all the pieces together
Now let us see how we can combine all the things that we discussed above and come up with a flow
Step 1: Create Lambda functions
We need to write a lambda which would read the payload and act on it according to the filters mentioned in the functions. I have used JIRA API to update the status and GIT API to fetch the branches.
Please refer the source code in the below mentioned link :
SOURCE CODE
Step 2: Create API gateways
Navigate to Amazon web services and type “API Gateway” on the console. click here to see how you can create a API gateway from scratch.
Once after creating API gateway, webhook will be generated.
The API gateways created above act as WEBHOOKS which in turn are linked to AWS lambda functions. These functions have the processing logic embedded in them.
Step 3: Link Webhooks in Github repository
Login to repository where the project is located and follow the below steps :
Settings → Webhook → Paste Webhook [Generated vai API gateway] on payload field → Update the content type as “application/json” → select “Send me everything” checkbox.
Now you have successfully linked the webhook in Github.
What happens after integrating webhook with GIT ?
For all the events triggered in GITHUB [linked repository], payload will be sent in the JSON format to the API gateway.
Based on my experience, below events are most commonly used to play with JIRA status
— New branch creation
— New PR
— PR Approve/Reject
— Merging the branches
Hope this document guides you to automate the JIRA Flow. I am pretty sure that your management would be happy about doing this.
Feel free to comment below if you have any queries.
Happy Automating :)