JSM/OpsGenie: Assign Jira issue to the user who acknowledged the alert

Still need help?

The Atlassian Community is here for you.

Ask the community

Summary

In some use cases customers might need to automatically assign a Jira ticket to the user who acknowledged it's corresponding OpsGenie alert. This knowledge base offers a workaround to achieve the same using automation for Jira and Jira Service Management integration in OpsGenie.

Environment

Jira Service Management cloud with OpsGenie.

Solution

Part 1: Setting up Jira Service Management integration from OpsGenie side

Using Jira Service Management new cloud integration

  1. Login to your OpsGenie site URL.
  2. Go to Teams > Integrations > Select Jira Service Management integration.
  3. Under Outgoing automation rule make sure that "Send alert updates back to Jira Service Management" checkbox is selected.
  4. Map the integration to add a comment on the ticket when the alert is acknowledged "Should be there by default however if it is not click on Add update rule and add the action":

Using Jira Service Management legacy cloud integration

  1. Login to your OpsGenie site URL.
  2. Go to Teams > Integrations > Select Jira Service Management integration.
  3. Under Opsgenie to Jira Service Management make sure that "Send alert updates back to Jira Service Management" checkbox is selected.
  4. Map the integration to add a comment on the ticket when the alert is acknowledged "Should be there by default however if it is not click on Add new action and add the action":

Part 2: Configure an automation rule in Jira Service Management to filter the username from comments added in part 1 and assign the tickets accordingly

For the automation rule to work as expected the name of the user needs to be unique

In Jira go to the project connected to OpsGenie integration click on Project Settings > Automation and follow the below instructions:

Automation rule overview

  • Trigger: When a comment is added to Jira issue. 
  • Conditions:
    • If user who added the comment is the same user configured for OpsGenie integration in our case the user is (Alert Integration).
    • If the comment body contained "acknowledged alert".
  • Actions
    • Extract the user name value from the comment body using text manipulation - Reference: Jira smart values - text fields.
    • Save the user name into a variable.
    • Send an API request to get the user name account ID (To update the Assignee user picker field the value must be the account ID for the user not their display name).
    • From the web response body extract the account ID.
    • Set the assignee field with the value of the account ID.

JSON file for the automation rule

Automation Rule configuration GIF

Parameters used in the automation rule

  • In the Create Variable action set the {{modifiedcomment}} variable to the below value:
{{issue.comment.last.body.replace("[Opsgenie]","").substring(0, issue.comment.last.body.indexOf("ack")).replace("acknowledg","")}}
  • Send web request action parameters:
    • URL: https://<Your-Site-Name>/rest/api/2/user/search?query={{modifiedcomment.urlEncode}}
    • Headers:
      • Authorization - Reference Link to generate the Authorization token Automation for Jira - Send web request using Jira REST API.

      • Once the token is generated convert it to base64 using the below steps: 


        How to convert to Base 64

        We need to encode the credentials "<EMAIL>:<API_TOKEN>with base64. We can make this through any online tool like Base64 encode.
        Note: Make sure not to include a line break at the end. 

        Apart from that, it's possible to Encode to base64 through terminal:

        $ echo -n "email@example.com:<YOUR_TOKEN_HERE>" | base64
      • Use base 64 in the authorization header
      • Content-Type - application/json.
    • Under Wait for response click on the checkbox for Delay execution of subsequent rule actions until we've received a response for this web request.

  • In the edit action for assign select smart value and set it to the following: {{webResponse.body.first.accountId}}.
Last modified on Jun 5, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.