Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,955
Community Members
 
Community Events
165
Community Groups

πŸͺ„ 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

4 comments

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

Like β€’ Manon Soubies-Camy likes this
Jack Brickey Community Leader Aug 07, 2021

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

Like β€’ # people like this
Alex Koxaras Community Leader Aug 07, 2021

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

Like β€’ Manon Soubies-Camy likes this

Hi @Manon Soubies-Camy 

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,

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you