Jira Salesforce Integration

Jira Integration With Salesforce

Integration means in the terms of technology is, add the functionality of others. It somewhere sounds collaboration of two different technology or software products accordingly.

In this blog, we are going to integrate the JIRA with salesforce using webhooks.

Jira Salesforce Integration

Below is the list of key concepts for completing this Jira Salesforce Integration.

  • Webhook
  • Site
  • Apex Web Services

Webhook – It is a kind of user-defined callback over HTTP. It can be used as a notifier which notifies your application when it comes into play. It is a very important part of JIRA to salesforce integration with any other technology.

In simple words, we can say that it kind of triggers which perform some appropriate action when an event occurs in the JIRA. Below is the list of event occurs in the webhook.

jira to salesforce integration

User related events

User

  1. Created
  2. Updated
  3. Deleted

There Are furthermore Types like Project-Related, Jira Configuration-Related, Jira Software- Related and they have their own events also. Which’ll discuss later.

How To Create a Webhooks?

Login To Your JIRA Account, Go To System Webhooks Or Use Quick Search then type Webhooks

  1. Click on Create a Webhook.
  2. A Form will come to screen fill the all required details like Name of the Webhook, Status, URL (It is the endpoint where it will send the Response in the form of JSON) You can also Call It as Endpoint.
  3. Select the Event On which webhook will fire like Create User, Update User, etc.
  4. Click on Create.

Note: Don’t Forget to remain ExcludeBody Unchecked if you want to get the JSON body in the response.

Site –

Site in salesforce is used for which you can give access to the VF page to End-Users and You can even call your apex service through an external site. You Don’t Need To Login to access the site in salesforce. It allows you to create public websites and applications that are directly integrated with your salesforce.com without authentication.

Here are the few steps to create a site in salesforce.

  1. Go To Setup Click on Quick Search Bar and Type Sites in the search bar.
  2. Create a custom domain first.
  3. Click on New to create your site after creating a domain.
  4. Set All the detail in the site like Site Label, Site Name, Active Home Page, etc.
  5. When You Think Your Site is ready then Activate your Site

jira integration with salesforce

Thus with the help of site, you can easily call your apex services from a third party website without login Id and Password.

Apex Web Services –

You can perform Rest and Soap web service operations through Apex
Classes. Make your method callable through the web. You have to give global access to all the method in apex web service. Use Global keyword before the name of the method to make it globally accessible.

Basic Syntax to create an apex class as web service.

@RestResource(urlMapping=’/give_any_custom_Url/’) global class Name_Of_Class{
@HttpGet // any annotation as per requirement global static Method_Name(){
// write your code here
}
}

Below is the list of annotation name and description of each annotation.

@HttpGet – Reads or retrieves records.
@HttpPost – Create records.
@HttpDelete – Delete Records.
@HttpPut – Used to update existing records or create records.
@HttpPatch- Used to update fields in existing records.

So now we know all the three key concepts to integrate the JIRA with the salesforce. Integration Task:

Create a record in the salesforce org automatically when we create any user in the JIRA.

Follow the below steps to create a record in Salesforce when we create any record in the JIRA.

Write an Apex Class as Web Service.

Code:

@RestResource(urlMapping=’/myurl/*’) global with sharing class RestTestController {
@HttpPost
global static void CreateRocord() { RestRequest request = RestContext.request; Blob body = request.requestBody;
String bodyString = body.toString();
Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(bodyString); Map<String,Object> objectlist = ( Map<String,Object> )m.get(‘user’);

Object email; Object Fname; Object Uname;
email = objectlist.get(’emailAddress’); Fname = objectlist.get(‘displayName’); Uname = objectlist.get(‘name’); Jira_User__c create = new Jira_User__c(
Username c = Uname.toString(), Name = Fname.toString(), Email_Address__c = email.toStrinote :

);
insert create; system.debug(‘=====’+bodyString);
}
}

Note :

  1. First Create a custom object named as Jira_User . Create three fields Name, Email_Address and Username
  2. Click on Site Label Public Access Settings Provide access to the object.
  3. Add the Apex class in your site by Public Access Settings Enable Apex Class Access Click on Edit Select the Apex Class from Available Apex Classes and Add the class in Enabled Apex Classes. Save.
  4. Make url like site-name.force.com/services/apexrest/apex_rest_endpoint/
    For example: my url was https://jiravidish-developer-edition.ap15.force.com/ services/apexrest/myurl/
  5. Go to your JIRA account create a webhook(as we already create above) 
  • Finally, click on create.
  • Keep the ExcludeBody Unchecked.
  • Go to user-related Events and click on create.
  • services/apexrest/myurl/
  • In the Url paste the above-created URL like https://jiravidish-developer- edition.ap15.force.com/
  • Click on enable
  • Name the webhook
  • Go To User – Management in the JIRA and click on create User and the details of the User and Click on Create.
  • Go To Your Custom Object in salesforce and you will find a record of the user that you have created in the Jira.
Posted in Jira Integration With Salesforce, Jira Salesforce Integration, Jira to Salesforce Integration, Jira with Salesforce, Mirketa, Salesforce, What is Jira Salesforce Integration.

Leave a Reply

Your email address will not be published. Required fields are marked *

*