Versions Compared

Key

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

Let's add the same comment to the linked issue.

...

  1. Create a new Action by clicking 
    Status
    colourBlue
    titleCreate
     button
  2. Enter a name: Get Linked Issue and click 
    Status
    colourBlue
    titleCreate
  3. Select Method:
    Status
    colourYellow
    titleGET
     and URL: <your_base_url>/rest/api/2/issue/{{issue.key}}?fields=issuelinks
    From the Atlassian REST API we can read that to fetch issue links by getting the issue JSON and further filter it by fields=issuelinks. call GET /rest/api/2/issue/{{issue.key}}?fields=issuelinks
  4. Select Authentication method: Basic Auth, specify a user with comment and browse permissions
  5. Add request headers, key: Content-Type with value application/json
  6. Click Triggers tab
  7. Select 
    Status
    colourGreen
    titleIssue Commented
     event
  8. On JQL Condition. When to execute the event(s) write project = TESTB AND issueLinkType = "is caused by"  to limit the trigger to the TESTB project and only the direction of "is caused by".
  9. Click 
    Status
    colourBlue
    titleSAVE
  10. (Optional) Click Test button (no issue key is needed) to and click Send, Then go 3 - View Execution Log.

Each result will have a response like the one below:

...

  1. Create a new Action by clicking 
    Status
    colourBlue
    titleCreate
     button
  2. Enter a name: Get Last Comment and click 
    Status
    colourBlue
    titleCreate
  3. Select Method:
    Status
    colourYellow
    titleGET
     and URL: <your_base_url>/rest/api/2/issue/{{issue.key}}/comment
    from the Atlassian REST API we can read that to fetch issue links by getting the issue JSON and further filter it by fields=issuelinks. call GET /rest/api/2/issue/{issueIdOrKey}/comment
  4. A new section called Variables is now displayed. On this section enter the 
    1. Variable name: inwardIssue and the JSON Path$.fields.issueLinks[0].inwardIssue.key

      The JSON path will return a variable with the value of the last comment
  5. Select Authentication method: Basic Auth, specify a user with browse permissions
  6. Add request headers, key: Content-Type with value application/json
  7. Click 
    Status
    colourBlue
    titleSAVE
  8. (Optional) Click Test button (no issue key is needed) to and click Send, Then go 3 - View Execution Log.

Part 3 - Add the last comment to linked issue

  1. Create a new Action by clicking 
    Status
    colourBlue
    titleCreate
     button
  2. Enter a name: Comment linked issue and (warning) note on the Select parent action choose to Get Last Comment which we created in part 1 and click 

    Status
    colourBlue
    titleCreate

    This will create a chained action that will be triggered directly after the response from the parent action is received. The response will be used as input variables this call using JSON Path expressions.

  3. A new section called Variables is now displayed. On this section enter:
    1. Variable name: inwardIssue and the JSON Path$.fields.issueLinks[0].inwardIssue.key
      Variable name: lastComment and the JSON Path$.comments[(@.length-1):].body
      The JSON path will return a variable with the value of the linked issue key.
  4. Select Method:
    Status
    colourYellow
    titlePOST
     and URL: <your_base_url>/rest/api/2/issue/{{inwardIssue}}/comment
    note that we now use the inwardIssue in the URL that we post to.
    From the Atlassian REST API we can read to comment on an issue we need to call POST /rest/api/2/issue/{{issue.key}}/comment
  5. Select Authentication method: Basic Auth, specify a user that has comment permission in the project
  6. Add request headers, key: Content-Type with value application/json
  7. On the Body section add the following

    Code Block
    {
        "body":"{{lastComment}}"
    }


  8. Click 
    Status
    colourBlue
    titleSAVE
  9. (Optional) Click Test button, Issue Key needs to be provided and click Send, Then go 3 - View Execution Log.