Salesforce JIRA Synchronous Integration

PURPOSE OF THIS INTEGRATION 

Boost your Salesforce CRM business task through smooth integration with Jira

  1. All teams on the same page: Better internal talk=happy customers. coordinated aggregated feedback and connections in both systems.

  2. Coincide your significant data to the other side: Teamwork simplified. Current & error-free updates about Salesforce objects or Jira data.

  3. Bid farewell to manual errors and duplication: Duplicate endeavors and manual data entry is gone. Empower mapping schemes to push or pull data among Jira and Salesforce.

Currently, We have integrated Salesforce with two of the JIRA platforms those are Service platform and Cloud Platform

Steps to create JIRA Cloud Platform account integrating with Salesforce

  1. To Create a Jira Account If You Don't Have One.

A. Click here to create an Account

ATLASSIAN > Sign up for your account

B. Verify your account email address.

ATLASSIAN | Verify your email

2. To Convert Your Account URL to .NET for JIRA Cloud API Platform.

A. Click here to convert URL

When we are done with the signup process of the JIRA platform account. We got an URL like https://id.atlassian.com. So to work with Salesforce JIRA integration we have to convert that URL with .net version(Refer above screenshot with site name field).

As we signed up with a JIRA platform account and they provided us default URL by using this we can’t call REST API.

To call REST API with this platform we use version 3 with username and API token with basic authentication.

To create a JIRA Service account with our custom .com URL like ‘https://jira.concret.com/’ we have to communicate with the Jira support team. To call REST API with this platform we use version 2 with username and password with basic authentication.

B. Fill your details and click Agree and Sign up.

After that please follow the steps as per JIRA standard steps.

3. To Generate an API Token.

A. Click here to generate an API Token and click on Create API token.

ATLASSIAN | Manage your account

B. Fill your API a label

Create your API token

C. A new API Token will be generated, Click View or Copy to Clipboard.

Your new API token

4. To Create A Public Site In Salesforce To Handle JIRA Webhook.

A. Go to Setup, in the Quick Find box, enter “Sites”, click on Sites, then select New.

Develop | Your Force.com Domain > Your Sites

Fill in the details to create a new Site, then click Save.

Concretion Jira SFDC Integration

Jira Cloud Platform Authentication:  To authenticate users by JIRA rest API for Cloud platform We need username and API tokens that we had created in previous steps.

To create JIRA API token for the cloud platform.

Code Example : 

public class HttpReq {

public static void testMethodToken(){

String userEmail = ‘your account username’;

String password = ‘your password’;

Http http =new Http();

HttpRequest req =new HttpRequest();

req.setEndpoint(‘https://testjiraintegration.atlassian.com/rest/api/2/issue/createmeta’);

req.setmethod(‘GET’’);

Blob headerValue = Blob.valueOf(userEmail+’:’+password);

String authorizationHeader = ‘Basic ‘ + EncodingUtil.base64Encode(headerValue);

system.debug(‘authorizationHeader ‘+authorizationHeader);

req.setHeader(‘Authorization’, authorizationHeader);

req.setHeader(‘cache-control’,’no-cache’);

req.setHeader(‘Content-Type’,’application/json’);

HttpResponse res = http.send(req);

System.debug(‘res :’+res);

System.debug(‘result of new :’+res.getBody());

}

}

Please click here

Jira Service Platform Authentication:To authenticate users by JIRA rest API for Service platform We need username and password.

public class HttpReq {

public static void testMethodToken(){

String userEmail = 'your account username';

String password = 'your password';

Http http =new Http();

HttpRequest req =new HttpRequest();


req.setEndpoint('https://testjiraintegration.atlassian.com/rest/api/2/issue/createmeta');

req.setmethod('GET’');

Blob headerValue = Blob.valueOf(userEmail+':'+password);


String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);


system.debug('authorizationHeader '+authorizationHeader);

req.setHeader('Authorization', authorizationHeader);

req.setHeader('cache-control','no-cache');

req.setHeader('Content-Type','application/json');

HttpResponse res = http.send(req);

System.debug('res :'+res);

System.debug('result of new :'+res.getBody());

}

}

Please click here

NOTE: These above code examples are only to check the JIRA account authentication using REST API’s

About Webhook: A webhook is a user-defined callback over HTTPS. You can use the JIRA webhook to notify your app or web application when certain events occur in JIRA.

To communicate with Salesforce From JIRA we used Webhook. 

For More Info Regarding Webhook Please click here

  1. Go to your .NET URL and then navigate to 

Jira Settings →System→WebHooks→Create a WebHook 

JIRA | System > WebHooks

After that we need to click on create a Webhook button once you click below, the screen is visible and we have to fill fields according to our requirement: 

JIRA | System > WebHooks > New Webhook Listener

URL looks like:

[java]{OrgUrl}/services/apexrest/jira_sfdc?issuekey=${issue.key}&projectkey=${project.key}&modifiedUser${modifiedUser.name}&commentId=${comment.id}&attachmentId=${attachment.id}[/java]

Services/apexrest/jira_sfdc: Is the prefix of request that we made when did activities from JIRA account to salesforce webservice.

Issuekey: This is the key to the issue which automatically populated according to our setting that we did while creating the webhook in JIRA according to activities that we had selected.

Projectkey: This is the key to a project which automatically populated according to our setting that we did while creating a webhook in JIRA according to activities that we had selected.

modifiedUser: Is the id of a user who updated the issue.

CommentId: Is the id of comment which automatically populated according to our setting that we did while creating a webhook in JIRA according to activities that we had selected.

AattachmentId: Is the id of attachment which automatically populated according to our setting that we did while creating a webhook in JIRA according to activities that we had selected.

Restrictions that we faced

  1. We can’t post feeds on chatter using connectedAPI from guest user profiles. That was the restriction that we faced while developing that.

  2. We have a limit of characters to post feed on chatter; it's about 10,000 characters.

  3. We have limitations that we can’t mention users in JIRA description, we can’t attach inline images in the description as well as while posting comments using salesforce with JIRA REST API'S.

  4. We can’t fetch issues and projects according to user permissions from JIRA. To do the same we need administrator permission at Jira end that seems to be not possible for all users.

  5. While implementing auth2.0 authentication with JIRA we can get access token but when we tried to hit API using that we can get status code 200 with a blank body that seems to be an issue at JIRA end. Auth 2.0 Blank body Issue and that seems to be working fine in postman.

References Those We Used While Implementing Whole Functionalities  

  • https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/

  • https://docs.atlassian.com/software/jira/docs/api/REST/

  • https://developer.atlassian.com/cloud/jira/software/rest/intro/

  • https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/

  • https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-basic-authentication-6291732/

  • https://community.atlassian.com/t5/Jira-questions/How-to-authenticate-to-Jira-REST-API/qaq-p/814987

    Thanks to our Salesforce Consultant Vijay Soni for this amazing blog post brilliantly written with detailed information.

Abhinav Gupta

First Indian Salesforce MVP, rewarded Eight times in a row, has been blogging about Salesforce, Cloud, AI, & Web3 since 2011. Founded 1st Salesforce Dreamin event in India, called “Jaipur Dev Fest”. A seasoned speaker at Dreamforce, Dreamin events, & local meets. Author of many popular GitHub repos featured in official Salesforce blogs, newsletters, and books.

https://abhinav.fyi
Previous
Previous

How Salesforce Health Cloud is Transforming the Healthcare Industry?

Next
Next

Succeed Professionally, Beat the Pandemic Blues!