πŸͺ„ Automate your Confluence documentation

The automation team recently released a new trigger: Project created. Which made me think: what if we could automatically create a new Confluence space when a new Jira project is created? It would save us a lot of time and ensure we always have a Confluence space associated to a Jira project. Let's do it!

 

πŸ”Ž Gather your API information

We will use Confluence Cloud API to automatically create a new space. Go here to create a new API token:

api-token.png

Save the generated token in a safe place.

 

🚧 Build the rule

Select the Project created trigger:

project-created.png

You can restrict the trigger to a specific project type - you may want the Confluence space to be created only for Software projects.

Then add a Send web request action. This can be a bit complicated, let me break it down for you:

  • Webhook URL:
https://yoursitename.atlassian.net/wiki/rest/api/space
  • Header:
    • Name: Authorization
    • Value: Basic followed by "email:apitoken" encoded in base64

Go to base64encode.org to generate your header value. Just type email:apitoken and hit encode. If my email is manon@gmail.com and my API token is 12345, here is how it should look like:

api-header.png

  • HTTP method: POST
  • Webhook body: Custom data
{
"key": "{{project.key}}",
"name": "{{project.name}}",
"description": {
"plain": {
"value": "This space is linked to Jira project {{project.key}}.",
"representation": "plain"}
}
}

We are using a bunch of smart values in the custom data so that, in both our new Jira project and new Confluence space, we have the same key and name. Read more here about smart values you can use.

Almost there! Here is the final Send web request action:

action.png

🚨 Improve your audit log

This is optional but I like to add log actions. It will come in handy if you need to debug your rule:

debug.png

You can use the following smart values:

{{webhookResponse.status}}
Space {{webhookResponse.body.key}} successfully created
Uh oh, something went wrong. Error {{webhook.Response.status}}

Note: if you do add these actions, remember to enable "Delay execution of subsequent rule actions until we've received a response for this webhook" in the Send web request action.

β›± Sit back and relax

You did it! A new Confluence space will now be automatically created whenever you create a new Jira project:

success.png

5 comments

Alexis Robert August 7, 2021

Great use of the Confluence API to automate Space creation ! Thanks @Manon Soubies-Camy _Modus Create_  

Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2021

@Manon Soubies-Camy _Modus Create_ , another awesome use of automation. Thanks for sharing.

Like β€’ # people like this
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2021

Very useful automation! This will come in handy! Great work @Manon Soubies-Camy _Modus Create_!

d.kirsching August 9, 2021

Hi @Manon Soubies-Camy _Modus Create_ 

Great work and helpful article ! Thx.

However, seems to be basic authentication is now deprecated in cloud.

Link doesn't work and I can't find the right article. Anyone have it ? 

Thx,

E Hanumanthu September 9, 2022

Hi @Manon Soubies-Camy _Modus Create_ 

Will the same configuration works in Data center as well? Can you please let me know.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events