The Now Platform® Washington DC release is live. Watch now!
on 07-27-2020 05:48 AM
Jira Cloud Software Integration with ServiceNow using Webhook
Prerequisite:
Use Case: Whenever a Jira issue created/updated in Jira cloud software it should create a record in ServiceNow.
Follow below steps:
Table Name: Jira Staging Table | u_jira_stage
Fileds:
Project Key | u_project_key
Project Name | u_project_name
Issue Key | u_issue_key
Issue Id | u_issue_id
Summary | u_summary
Description | u_description
2.Create Scripted REST API
Create a scripted REST API resource to define the HTTP method, the processing script
Before you begin
Role required: web_service_admin
About this task
By default, any new Scripted REST API resource you create contains an ACL that prohibits users with the snc_external role from making requests to the API.
Procedure
The resource name affects the URI for sending requests to the API.
6. In the Script field, define how the operation parses and responds to requests.
Copy below code and paste in Script:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
try {
//gs.log("Jiralog "+JSON.stringify(request.body.data));
var requestBody = request.body.data;
// read the request boy and map with staging table fileds and creat/update a issue record
gs.log('jiralog '+ requestBody.issue.fields.project.name);
var jr= new GlideRecord('u_jira_stage');
jr.addQuery('u_issue_id',requestBody.issue.id);
jr.addQuery('u_project_key',requestBody.issue.fields.project.key);
jr.query();
if(!jr.next())
{
jr.initialize();
jr.u_project_name = requestBody.issue.fields.project.name;
jr.u_project_key = requestBody.issue.fields.project.key;
jr.u_issue_id = requestBody.issue.id;
jr.u_issue_key = requestBody.issue.key;
jr.u_summary= requestBody.issue.fields.summary;
jr.u_description=requestBody.issue.fields.description;
jr.insert();
gs.log('Jira Issue created: '+jr.u_issue_id);
}
else{
jr.u_summary= requestBody.issue.fields.summary;
jr.u_description=requestBody.issue.fields.description;
jr.update();
gs.log('Jira Issue updated: '+jr.u_issue_id);
}
}
catch(ex) {
var message = ex.message;
}
})(request, response);
7.Click Submit.
3. Create an API token
Create an API token from your Atlassian account:
Note:
Refer: https://confluence.atlassian.com/cloud/api-tokens-938839638.html
4.Create a Jira User in ServiceNow
Username: Jira login email Id
Password: API Token
5. Registering a webhook
What is webhook?
A webhook is a user-defined callback over HTTP. You can use Jira webhooks to notify your app or web application when certain events occur in Jira. For example, you might want to alert your remote application when an issue is updated or when sprint is started. Using a webhook to do this means that your remote application doesn't have to periodically poll Jira (via the REST APIs) to determine whether changes have occurred.
To register a webhook, you can use any of the following methods:
Registering a webhook via the Jira administration console
In our scenario:
Refer: https://developer.atlassian.com/server/jira/platform/webhooks
That’s all, now you can login to Jira and test the configuration.
Let’s create an issue:
Now login to ServiceNow and check if the issue got created in Jira staging table
In case of queries feel free drop your comment on the article.
If you like this article please mark it helpful !!
Regards,
Aj
+91-9769949577
https://www.linkedin.com/in/ajay-chavan-profile
Hi AjayChavn
my name is Ajay I have a query
is it a bi-directional integration concept?
Thanks for sharing the steps. It's a very nice and detailed article. One question - is it possible to get JIRA dev environment like we get servicenow developer instance ? Thanks again
Yes, you can get free instance
Hello,
where and how do you manage authentication to ServiceNow ?
Thank you
Hi Ajay,
It is not working for me. Could you help me on this.
Thanks
Hi Ajay,
Thanks for the post.
I configured everything on both sides. I am able to create a record on the staging table in our Dev instance, which means that at least on the instance side, things are configured properly. However, nothing seems to come from Jira's side. The webhook is configured correctly, as far as I can tell from your post and from atlassian documentation (Webhooks (atlassian.com))
Any ideas on how to troubleshoot are welcome.
harel
This does not works when authentication is checked in Scripted rest api ,any idea how we can maintain authentication in servicenow
Hi Ajay,
It is not working for me. Could you help me on this.
Thanks
In order to implement authentication you have to get creative. You need to share a key as url parameter and validate that as part of scripted API, since there was no provision to provide user name and password in jira webhook we need to take this workaround.
Hi Chavan,
From the above mentioned script where you have used GET methods to retrive data's from Jira to Snow, i can see you are mapping the fileds in Jira stage table and insering that record in jira stage table via ServiceNow scripted rest message.
could you please tell me detaily how it will work for ServiceNow inbound integration?