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!
We will use Confluence Cloud API to automatically create a new space. Go here to create a new API token:
Save the generated token in a safe place.
Select the Project created trigger:
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:
https://yoursitename.atlassian.net/wiki/rest/api/space
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:
{
"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:
This is optional but I like to add log actions. It will come in handy if you need to debug your rule:
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.
You did it! A new Confluence space will now be automatically created whenever you create a new Jira project:
Manon Soubies-Camy
Atlassian consultant
France
266 accepted answers
5 comments