Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

From Confluence create Jira task and add link on page, link existing Jira issues on page to new task

Ohey, we have an existing automation that runs monthly and puts an "engineering-rca" label on any new RCA Confluence pages ("publishing" pages labeled engineering-rca-draft by replacing them with engineering-rca). We wanted to add to that, so that for any page that has the label engineering-rca added:

  • create a task in RETRO project with same title as the RCA page.

    • Fill in the Documentation Link field with the link to the RCA page.

    • Fill in the Description with the link to the RCA page.

    • Assign the issue to the listed owner of the the RCA page.

    • Add the label engineering-rca

  • add a link for this issue to the RCA page (preferably at the top), if possible.

  • Bonus: link the Jira issues listed in the Preventive Actions section of the RCA Confluence page to the RETRO RCA ticket, or suggest an alternative way to approach this.

This was accomplished with two automations:

Confluence

  • Scope: all Spaces - must Check to allow other rule actions to trigger this rule.

  • When Page labeled with engineering-rca

  • Create new Task in RETRO

    • Summary: {{page.title}}

    • Description: [{{page.title}}|{{page.url}}]

    • Assignee: {{page.owner.accountId}}
    • Labels: engineering-rca

    • Additional fields:

      {
          "fields": {
              "Documentation Link": "{{page.url}}"
          }
      }
  • Check to see if there is already a RETRO task associated with this page (in the event that the engineering-rca label was removed and then added back)

    • Web request for API Jira for issues linked to this page that also contain the engineering-rca label.

      • issue in (issuesWithRemoteLinksByGlobalId('appId=OURAPPID&pageId={{page.id}}')) and labels = "engineering-rca"

    • Only proceed if size of results = 0

    • (appId details below)
  • Send web request to obtain existing page content

  • Create taskParagraph variable to prepend new task to top of page inside of an Info panel.

    • <ac:structured-macro ac:name="info" ac:schema-version="1" ac:macro-id="OURPANELMACROID">
          <ac:rich-text-body>
              <p>Jira Issue: <ac:structured-macro ac:name="jira" ac:schema-version="1" ac:macro-id="OURJIRAMACROID">
                  <ac:parameter ac:name="key">{{createdIssue.key}}</ac:parameter>
                  <ac:parameter ac:name="serverId">OURJIRASERVERID</ac:parameter>
                  <ac:parameter ac:name="server">System Jira</ac:parameter>
                  </ac:structured-macro> 
              </p>
          </ac:rich-text-body>
      </ac:structured-macro><p>
    • (This content above was obtained by copying it from the storage format of an existing page.)

  • Send web request to update existing page content

    • PUT https://OURSITE.atlassian.net/wiki/api/v2/pages/{{page.id}}

    • Custom data:

      {
        "id": "{{page.id}}",
        "status": "current",
        "title": "{{webResponse.body.title}}",
        "body": {
          "representation": "storage",
          "value": "{{taskParagraph.jsonEncode}}{{webResponse.body.body.storage.value.jsonEncode}}"
        },
        "version": {
          "number": {{webResponse.body.version.number.plus(1)}},
          "message": "Adding RETRO Task"
        }
      }

Screenshot 2025-05-04 at 12.10.43 AM.png

Jira

[Caveat: Linking of issues on RCA Confluence Page relies on “automatic” creation of remote links, which apparently is triggered by selecting Inline, Card, or Embed Views for a Jira “Smart Link”. (I opened a ticket about this.]

Screenshot 2025-05-04 at 12.11.53 AM.png

1 comment

Darryl Lee
Community Champion
May 5, 2025

So yeah, when everything is working right, adding the engineering-rca label to this page resulted in a new task RETRO-364 being created:


Screenshot 2025-05-05 at 10.23.12 AM.png


And then the existing tickets (well, the four that are in "Inline" view) were linked to that ticket:

Screenshot 2025-05-05 at 10.24.45 AM.png


Note about Documentation Link custom field

The Jira automation needs a Page Id to be able to do the JQL query looking for issues mentioned on the page. Having the URL of the Page stored in a custom URL field (Documentation Link) makes extracting the Page Id very simple:

  • Create pageId variable by extracting Page Id from Documentation Link:
    {{issue."Documentation Link".match("./pages/(.)")}}

I guess if you didn't have such a field, you could use the remotelink API endpoint to get the URL and pageId:

remotelink.jpg

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events