Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jira Automation: Updating a Confluence page with information from Jira issues

This article provides instructions for creating a solution that utilizes Jira Automation and the Confluence REST API to update a Confluence page with information from Jira issues.
For instance, When a label is added to a Jira issue, the label and the issue key should be added to an existing Confluence page.

Solution

The plan is as follows:

  1. Get the page details using the REST API endpoint Get page by id.

  2. Retrieve the page content and the page version.

  3. Update the page using the REST API endpoint  Update page. This Endpoint overwrites the existing page content. Therefore, we needed to retrieve the page content in Step 2.

Get Page ID

  • Use this API endpoint Get pages to get the Confluence page id.
    Or you can get the page id from the Confluence page:

    • Go to the ellipses (...) at the top-right of the page > Advanced Details > Page Information

Get the version number

  • Use this API endpoint Get page by id to get the page version.

  • Use Jira smart values to save the page version.

    {{webResponse.body.version.number}}

Get the page content

  • Use this API endpoint Get page by id and append this parameter ?body-format=storage at the end of the URL to get the page content. Example:

    https://<Cloud URL>/wiki/api/v2/pages/<Page ID>?body-format=storage
  • Use Jira smart values to save the page content.

    {{webResponse.body.body.storage.value}}


Build the automation rule

  1. Add a Field value changed trigger and select the labels field when a value is added.

  2. Add a Send web request to get the page information and add the following information:

    • Web request URL: https://<Cloud URL>/wiki/api/v2/pages/<Page ID>?body-format=storage

    • Method: GET

    • Web request body: Empty

    • Select the checkbox: "Delay execution of subsequent rule actions until we've received a response for this web request"

    • Add the following headers:

      • Accept: application/json

      • Content-Type: application/json

      • Authorization: Basic <encoded Email:APIToken>
        GETpageinfo.png

 

  1. Add another Send web request to update the page and add the following information:

    • Web request URL: https://<Cloud URL>/wiki/api/v2/pages/<Page ID>

    • Method: PUT

    • Web request body: Custom data

      {
        "id": "<Page ID>",  //pageID
        "status": "current",
         "title": "<Page Title>",  //Pagetitle
         "body": {
          "representation": "storage",
          "value": "{{webResponse.body.body.storage.value}}\n{{issue.key}} {{issue.labels}}" //Page current content + new content
        },
        "version": {
          "number": "{{#=}}{{webResponse.body.version.number}} + 1{{/}}"  //Increment page version
        }
      }
    • Add the following headers:

2 comments

YY哥
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 3, 2024

 Hi @Hala ElRoumy 

Thanks for your sharing.

Automation for Jira (A4J) is a Jira App, which was acquired by Atlassian. And the rebradning name is Jira Automaiton, I think.

Thanks,

YY哥

Like Hala ElRoumy likes this
Hala ElRoumy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 4, 2024

Updated. Thanks @YY哥

Like YY哥 likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events