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

Create Confluence Page Post functions automatically creates Confluence pages via JIRA workflow. 

To add Create Confluence Page using a template page post function, go to the desired transition of your workflow, switch to Post functions tab and click on Add post function link. Then locate "Create Confluence Page using a template page" post function and click Add button.

Image Removed

Type of Confluence Connection

You can define the Confluence connection type. You have two options;

  1. Credential: Confluence Integration Credential which defined here. If you don't define it, you won't see this option.
  2. Application Link: Use Application Link when a connection to Confluence. You can select any application link which type is Confluence in your JIRA. If you don't have any application link, you won't see this option.

Image RemovedImage Removed   

Condition           

 In

Button handy
blankfalse
color#EBECF0
nameCloud
linkhttps://appfire.atlassian.net/wiki/spaces/EIFJC/overview
width84
Button handy
blankfalse
color#0052CC
nameData Center
linkhttps://appfire.atlassian.net/wiki/spaces/EI4J/overview?homepageId=11206659
width105

Panel
panelIconIdatlassian-info
panelIcon:info:
bgColor#F4F5F7

This page is about Easy Integrations for Jira DC. Using Jira Cloud? Click the Cloud button above.

Easy Integrations offers a post function to generate Confluence pages based on Jira workflow transitions.The issue's field/custom field values can be used to generate Confluence pages from templates.

On this page:

Table of Contents
minLevel1
maxLevel6
outlinefalse
styledefault
typelist
printabletrue

Steps

  1. Go to the desired transition within your workflow, switch to the Post functions tab, and click on the Add post function link.

  2. Locate the EIS - Create a Confluence Page post function and click the Add button.

    Image Added

...

Post Function Name

You can create a name for your post function.

...

Type of Confluence Connection

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

  1. Credential: Choose Credential if you want to use Confluence connection which is defined via the Easy Integrations Confluence setting. If there is no defined credential, this option will not be seen.

    Image Added
  2. Application Link: If you want to use the Jira application link then choose this option. If there are multiple application links you can choose an appropriate one and if there is no application link in your Jira, this option will not be seen.

    Screenshot 2024-06-27 at 12.03.55.pngImage Added

...

Condition

In this part, you can add a condition for the confluence page.   By By default, it has can only return true statement statements 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 Removed                                                                                                     

...

Below is a sample code snippet for a condition

...

that checks the logged-in user should be the reporter of the issue

...

:

Condition Code Example

true
linenumbers
Code Block
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)

...

Template

...

For the template

...

, you have two options:

  1. Templates

  2. Confluence Page

You can choose any global and space templates or 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 the Template or Confluence Page. 

Warning

We're not currently supporting Confluence Templates, please select any page as a template.

...

Info

If you leave the Space Key input blank, it will search only global Templates.

...

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 to be automatically created. Image Removed

...

Set Folder and Template Page(s) Dynamically

If the template page's ID is stored in a custom field, use the below code in the Parameters section to get the value. 

...

Use the same parameter key (in this example templateID) must be used in the ID text input in curly braces (as seen below {{templateID}} ).

...

Page Content

Page The 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

...

  • the Jira issue key) would be wise.

  • Request

...

  • Body: Leave this blank if you are not an experienced user

...

  • and you want to follow the standards. Click on the Load default body to modify

...

  •  link if you want to see and change the request JSON body. Otherwise, leave it blank.

  • Parameters:

...

  • You can define static or dynamic parameters here using Groovy Script. Some sample parameters are shown below.

...

Image Removed

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_11100'))
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.

Image Removed

...

  • Image Added

A code example is provided below:

Code Block
def parameters = [:]

parameters["assignee"] = issue.assignee
parameters["reporter"] = issue.reporter

def userManager = ComponentAccessor.getUserManager()
parameters["userDisplayName"] = userManager.getUserByName("someUserName").getDisplayName()

def cf = customFieldManager.getCustomFieldObject("customfield_xxxxx")
def price = issue.getCustomFieldValue(cf)
parameters["price"] = (null != price) ? price : "No price defined"

return parameters

...

Update Page

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

...

View of Post Function

...

To automatically link the Jira issue and Confluence page, use the Jira macro in Confluence. You can find a demonstration of its usage here.