Let's add the same comment to the linked issue.
...
- Create a new Action by clicking button
- Enter a name: Get Linked Issue and click
- Select Method: 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
- Select Authentication method: Basic Auth, specify a user with comment and browse permissions
- Add request headers, key: Content-Type with value application/json
- Click Triggers tab
- Select
Status |
---|
| |
---|
colour | Green |
---|
title | Issue Commented |
---|
|
event - 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".
- Click
- (Optional) Click Test button (no issue key is needed) to and click Send, Then go View Execution Log.
...
- Create a new Action by clicking button
Enter a name: Comment linked issue and note on the Select parent action choose to Get Linked Issue which we created in part 1 and click
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.- A new section called Variables is now displayed. On this section enter the Variable name: inwardIssue and the JSON Path: $.fields.issueLinks[0].inwardIssue.key
The JSON path will return a variable with the value of the linked issue key. - Select Method: and URL: <your_base_url>/rest/api/2/issue/{{issue.keyinwardIssue}}/watcherscomment
note note that we use double curly brackets {{issue.key}} to operate on the issue. Within the brackets, we can access any issue propertynow use the inwardIssue in the URL that we post to.
From the Atlassian REST API we can read that to add watchers to comment on an issue we need to call POST /rest/api/2/issue/{issueIdOrKey{issue.key}}/watcherscomment - Select Authentication method: Basic Auth, specify an admin a user that can read groups in JIRA.has comment permission in the project
- Add request headers, key: Content-Type with value application/json
In On the Body section add the following payload body
Code Block |
language |
---|
java | {{#watchers}}
"{{.}}" {{/watchers}} {{^watchers}}
"body":"{{.lastComment}}"
{{/watchers}} |
Since we get an array of usernames as a result from the JSON Path$.actors[*].name value [rick,mr.bot@rixter.s] and the API endpoint requires a comma-separated list of strings we need to render that in the body using the Mustache template. Accessing the watchers variable with double brackets and then using the iteration method to walk through the list. Therefore the # and / syntax. The ^ and / removes the last comma.
- Click button
- (Optional) Click Test button (no issue key is needed) to , Issue Key needs to be provided and click Send, Then go View Execution Log.