Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Excerpt
hiddentrue

 Post function to automatically create Confluence page within JIRA workflow

...

  • Go to the desired transition of your workflow, switch to Post functions tab, and click on Add post function link.
  • Locate Create Confluence Page using a template page post function and click Add button.

Image Removed

...

Image Added

...

Post Function Name

You can give a name to your post function.

Image Added

...

Type of Confluence Connection

This initial step is to select the Confluence connection. There are two options:

  1. Credential: Choose Credential if you want to use Confluence connection which is defined via Easy Integration Confluence setting. If there is no defined credential, this option won't be seen.
  2. Application Link: If you want to use the Jira application link, choose this option. If there are multiple application links, you can choose an appropriate one, if there is no application link in your Jira, this option won't be seen.

Image RemovedImage RemovedImage AddedImage Added   

...

Condition           

 In this part, you can add a condition for the confluence page.  By default, it has only return true statement which means that the Confluence page will be created. However, you can type your own script in order to programmatically add a condition to create a Confluence page or not. 

Image RemovedImage Added                                                                                                     

...

Code Block
firstline1
titleCondition Code Example
linenumberstrue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
 
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
log.info("current user:" + currentUser.username)
def reporter = issue.reporter.username
log.info("reporter: " + reporter)
return reporter.equals(currentUser.username)


...

Selecting the template page

You can choose any page in your Confluence to be a template for this post function. See creating a template page with dynamic parameters.
There is a Confluence Search input in which you can start typing the title of Confluence Page. 

...


The selected page will automatically fill Page ID. If you know the page ID of the template page, you can skip the above step and fill the ID instead.
Image Removed
Image Added

...

Selecting the folder where generated pages will be created

Similar to the first step, choose the folder (Confluence Page) where you want your automatically created Confluence pages will be created. 
Image RemovedImage Added

...

Page Content


Page title and content are defined in this section.
Page Title: As you know, Confluence does not permit the same page title within the same space. So, adding a unique key to the page (like JIRA issue key) would be wise
Request body: Leave blank if you are not an experienced user, and you want to follow the standards. Click on the Load default body to modify the link if you want to see and change the request JSON body. Otherwise, leave blank.
Parameters: Add static or dynamic parameters here. Some sample parameters are shown below. These parameters can be used within double curly-braces in a Confluence page

Image RemovedImage Added

Some code example below;

Panel

assignee = $issue.assignee or {{issue.assignee}}
reporter = {{issue.reporter}}
date = $issue.created
formattedDate = $DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format($issue.created)
productName = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11100'))
price = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11102'))
displayName = $user.displayName
userDisplayName = $ComponentAccessor.getUserManager().getUserByName("someUser").getDisplayName() // you can also use ComponentAccessor
story point = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11101'))
environment = Production
comment = $comment // this is the comment that is passed through the transition

...

Info

If you want to leave empty if no value specified, add ! after $ sign. e.g.:

story point = $!issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11100'))


Click the Add button, and that's it. Please do not forget to publish the workflow.


...

Update Page

If you enable this option, post function will update the Confluence page if it already exists.Image Removed

Image Added


...

View of Post Function

Image Added

Info

To automatically link the JIRA issue and Confluence page please use JIRA macro in Confluence. (See sample usage here)

...