You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!

1

Create a Jira issue when a page or blog post is approved - Comala Document Management integration

Overview

This script allows Comala Document Management users to automatically create a Jira issue once a page is approved in a Confluence workflow.

Example

Your team works collaboratively to produce a Confluence page that details feature descriptions for proposed new functionality. When the Confluence page is finished, you request approval from management.

When an identified approver clicks the Approve button, this script creates a Jira issue linked to the Confluence page.

Good to Know

  • The integration requires both Comala Document Management and Scriptrunner to be installed on the same Confluence instance. You must also clearly identify the "final" states of your Workflow in the script for it to work correctly.
  • This is a Custom Event Listener that listens for an ApprovalApprovedEvent.

Additional Information

We have a blog post that shows you how to use ScriptRunner's integration with Comala Document Management to automatically create a Jira issue when a Confluence page is approved.

Requirements

  • Confluence Confluence (6.6 - 6.15)
  • ScriptRunner for Confluence ScriptRunner for Confluence (5.6.14)
    
import com.atlassian.applinks.api.ApplicationLinkService import com.atlassian.applinks.api.application.jira.JiraApplicationType import com.atlassian.sal.api.component.ComponentLocator import com.atlassian.sal.api.net.Response import com.atlassian.sal.api.net.ResponseException import com.atlassian.sal.api.net.ResponseHandler import com.onresolve.scriptrunner.runner.customisers.WithPlugin import groovy.json.JsonBuilder import com.comalatech.workflow.event.ContentApproveEvent import static com.atlassian.sal.api.net.Request.MethodType.POST @WithPlugin('com.comalatech.workflow') def appLinkService = ComponentLocator.getComponent(ApplicationLinkService) def appLink = appLinkService.getPrimaryApplicationLink(JiraApplicationType) def applicationLinkRequestFactory = appLink.createAuthenticatedRequestFactory() def event = event as ContentApproveEvent def approvalComment = event.approval.comment def body = new JsonBuilder([ fields: [ project : [key: 'PROJECT_KEY'], summary : 'Confluence Page Created', description: "A page has been created and approved by administrators with comment ${approvalComment}.", issuetype : [name: 'Story'] ] ]).toString() def request = applicationLinkRequestFactory.createRequest(POST, '/rest/api/2/issue') .addHeader('Content-Type', 'application/json') .setEntity(body) request.execute(new ResponseHandler() { @Override void handle(Response response) throws ResponseException { if (response.statusCode != 201) { log.error("Creating Jira issue failed: ${response.responseBodyAsString}") } } })
Discovered an issue? Report it here

Suggested for you