Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

With Easy Integration's Issue Listeners, you can integrate your Jira with your internal/external systems by calling REST services accordingly. In On this page, you will explore find out how to define a listener and configure the REST service.

Listeners can be accessed in the within Easy Integration's admin UI (Jira admin cog icon > Manage apps > Easy Integrations Menu > Listeners (EI)).  


Image RemovedImage Added

 On this page, you can find The above page shows all the listeners that you have already defined. Also, you can;You can also:

  1. Create a new listener.
  2. Edit an existing listener.
  3. Delete an existing listener listener.

...

To

...

Create a

...

New Listener

  1. Click on the Add New Listener button.
  2. Fill in the information regarding about the listener.


Image RemovedImage Added

...

  1. Create a name

...

  1. for the listener.
  2. Select projects

...

  1. that you want to listen

...

  1. out for issue events and call REST services. You can also choose the All Projects option.
  2. Similarly, select issue types. You can also choose the 

...

  1. All Issue Types option.
  2. Select the issue event(s) which you want to listen to. You can select multiple issue events.

Script for

...

Execution

In this part, you can add a condition for the listener. 

By default, it only has only the return true statement which means that the listener will execute the REST call. However, you can type your own script in order to programmatically add a condition to execute the REST service or not.

Image RemovedImage Added
Below , is a sample code snippet for a condition which that checks the logged-in user should be the reporter of the issue:

Code Block
languagegroovy
titleExecute Code
linenumberstrue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
log.info("current user:" + currentUser.username)
def reporter = issue.reporter.username
log.info("reporter: " + reporter)
return reporter.equals(currentUser.username)


REST Service Details

In this part, REST details (URL, method, headers, body, credential, ..etc) are filledcreated.

Image RemovedImage Added

  1. The endpoint of the REST service. You can type any dynamic parameter here using double curly braces. (e.g.

...

  1.  http://mycompany.com/api/book/{{bookId}} assuming bookId is defined

...

  1. within the Parameters section which is described below.
  2. Select the Http Method (GET, POST, PUT, DELETE).
  3. Define your HTTP header key/value sets in separate lines (as

...

  1. shown in the screenshot).
  2. Type the JSON request body

...

  1. - you can use dynamic parameters here as well.
  2. Define all your dynamic parameters here. You can add static values as well as the dynamic values of fields/custom fields in the

...

  1. Jira issue.

...

  1. Below are some sample usages

...

  1. .
  2. Choose the authorization type. Currently, BASIC Authentication is supported.

...

  1. If you choose the Basic Authorization Type, the credential

...

  1. will become active

...

  1. and the credentials you defined in the Credentials

...

  1.  section will be listed.

Headers code example;:

Code Block
titleHeaders
linenumberstrue
Accept=application/json

Request body code example;:

Code Block
titleRequest Body
linenumberstrue
{
   "item"  : "{{productName}}",
   "price" : "{{price}}",
   "date"  : "{{date}}",
   "item"  : "{{productName}}",
   "owner" : "{{user.displayName}}"
}

Parameters code example;:

Code Block
titleParameters
linenumberstrue
assignee    = $issue.assignee or {{issue.assignee}}
reporter    = {{issue.reporter}}
date        = $issue.created
formattedDate = $DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format($issue.created)
productName = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11100'))
price       = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11102'))
displayName = $user.displayName
userDisplayName = $ComponentAccessor.getUserManager().getUserByName("someUser").getDisplayName() // you can also use ComponentAccessor
comment     = $comment // this is the comment that is passed through the transition


For more details and utils for on parameter assigning see Parameters usage examples , see the Parameters Usage Examples page.
Also see ComponentAccessorUserIssue and Status API  and Status API for all properties and methods.


Run asynchronously?

Image RemovedImage Added

In this section, you can enable async to execute the REST service asynchronously. There are a couple of reasons why you may want to execute asynchronously.

  1. Executing synchronously makes the user wait for the transition for longer than usual. If the host of the REST service responds late or there is a connection time out between the JIRA Jira server and the host, the users user will wait for the spinner for a lotlong time. So, it may be wise to enable async if your REST service responds slowslowly.

  2. Some issue parameters may wait for calculation or reindexing. Some plugins may work in the background to populate the actual result of a custom field and you may want to use that value. 

There is a scheduled task named Easy Integrations for JIRA Jira - Async Rest Caller Sched.


Post

...

Operations

In this section, you can configure will find out how to update a custom field based on a value in the REST response.

...

Image Added

  1. First, tick the Update custom field checkbox.

...

  1. Select the custom field that you want to update from the drop-down menu.
  2. Type the jsonpath accordingly to select the value. If the result is not JSON and you want to update a custom field with the body itself, just leave this textbox empty.

Image Removed

  1. Click the checkbox if you want to update any custom field
  2. A select custom field which will be update
  3. Type jsonpath for custom field


See jsonpath examples page See the jsonpath examples page for jsonpath samples.