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:

9 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
vincenzo_spatafora June 10, 2024

Hi @Hala ElRoumy, thanks for sharing that.

What about the case where you need to edit/update (PUT) a specific cell of a table which is in Confluence?

See please attached file showing the table where I would like my automation rule is update the status of the JIra tickets (as their transition changes).

Thanks in advance, Vincenzo.

Table_in_Confluence.PNG

vincenzo_spatafora June 10, 2024

Hi @YY哥, thanks for that.

What about the case where you need to edit/update (PUT) a specific cell of a table which is in Confluence?

See please attached file showing the table where I would like my Jira automation rule to update the status of the JIra tickets (as their transition changes).

I use Jira DC version 9.12.5.

Thanks in advance, Vincenzo.

 

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.
June 10, 2024

Hi @vincenzo_spatafora 

About jira issue status update in confluence page, if you insert jira issue macro into the page, the jira issues' status will change accordingly in the confluence page (refresh) once jira issue's status is transitioned. 

I don't for your scenario, it seems we don't need automation.

Like vincenzo_spatafora likes this
vincenzo_spatafora June 10, 2024

Thank You @YY哥, thanks for your comment.

Kind Regards, Vincenzo. 

Like YY哥 likes this
vincenzo_spatafora June 10, 2024

And @YY哥

would you know the syntax to add 2 (or 3) issues key in the confluence macro?

I have tried the follwoing but it doesn't work; it picks alwasy the first issue key.

Thanks in advance, Vincenzo.

Confluence_Macro.PNG

 

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.
June 10, 2024

key in (xx,  xx)

Like vincenzo_spatafora likes this
vincenzo_spatafora June 10, 2024

Thank You very much @YY哥 , very appreciated.

Kind Regards, Vincenzo.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events