It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automatically create a page under project on confluence when a JIRA issue is created.


Is there a way to created pages automatically on confluence under a project when an issue is created on JIRA under the project? Currently, in our evaluation setup we are creating manual pages on confluence but this does not appear to be a viable solution for us in long term :(

6 answers

Update: see https://jamieechlin.atlassian.net/wiki/display/GRV/Interacting+with+Confluence+from+JIRA

Old answer from 2.5 years ago:

It doesn't take much programming. Eg, using the script runner plugin, set a script post-function on issue create, the script might be:

package examples

import org.swift.common.soap.confluence.ConfluenceSoapServiceServiceLocator

def locator = new ConfluenceSoapServiceServiceLocator()
def service = locator.getConfluenceserviceV2(new URL("http://confluence.acme.com"))
def token = service.login("admin", "password")
def page = service.getPage(token, "MYSPACE", issue.summary)
page.content = issue.description
service.updatePage(token, page)

I haven't tested that and haven't used the confluence SOAP API for a while so it might not work. Also I used the compiled stubs from Bob's CLI distro, hence the org.swift, but I could have compiled them myself. To work this needs the confluence-soap-4.0.0.jar from Bob's CLI in the WEB-INF/lib of jira (or compile the stubs yourself and add the jar).

A good enhancement would be to use applinks rather hard-wire the admin password, and maybe to keep the confluence page up to date with a listener... although that would seem to defeat the purpose come to think of it.

 

Thanks Jamie and Bob. Unfortunately, I do not have any webservices / J2EE programming experience. I shall seek help from my collegues to accomplish this. Thanks!

Is there a way to not have a password in the groovy script and use the logged in user. I mean use the SSO

1 vote

In JIRA 5.0 (coming soon), you've got the ability to link an issue to Confluence pages: http://confluence.atlassian.com/display/JIRA/JIRA+Remote+Issue+Links

You
could create a plugin that when a new issue is created, Confluence pages are created and the linked to the issue

Out of curiosity, what are you using this for? What is the business scenario which wants this? For specs? Other things?

The business case is very simple -

We want to track the workflow of issue on JIRA and at each step of the workflow we have exit criteria defined which are mostly documents.Ofcourse, some comments revisions go on these docs. We want to be able to put all the docs in confluence ten reference those links on JIRA issue. The current design of Jira-Confluence does not auto-create pages when jira issues are created so there is some level of resistance to adopt confluence.

Another capability is to be able to come up with auto-screens as defined on Jira workflow on confluence. At the current setting, I do not see this option too. What are your thoughts?

Not that I am aware of without programming. I am working on a something similar (without a programming requirement), but it will not be available for a while.

Thanks Bob. I wish your plugin is available at the earliest. I am sure everyone wants to use it.

Hey Bob,

How can I use your CLI Plugin for JIRA in order to generate a Confluence article whenever I create an Issue in JIRA?

Thanks!

Hey BoB I am facing still problems in implementing your code in jira for automated page creation in confluence.

Please help me by elaborating how to implement this code in jira. I have tried the wayyou have mentioned but I didnt get how to apply script runner in the project..??

Please Clarify

I think you are talking about Jamie's answer using script runner. I can't help you there other than to say follow the instructions he provided. My non-programming solution is not available at this time. I will post here when it is.

Try reading the comprehensive script runner documentation. If you are not technical I'd advise you to wait for Bob's non-programming solution.

Any news Bob?

i will check script too

Yes, CLI Plugin for JIRA. It has been available for some time, but I lost track of this post :(.

Had you picked a solution yet? I am facing the same problem but in my case I do have an ancient jira 3.x plugin that was doing this and I need to replace it with something else because it is not compatible with newer jira versions and also it is too hard to maintain or configure.

Hi, can anybody help me with that task? I've added Custom script post-function with the following code on the transition:

package examples.docs
 
import com.atlassian.applinks.api.ApplicationLink
import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import com.atlassian.jira.issue.Issue
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.sal.api.net.Request
import com.atlassian.sal.api.net.Response
import com.atlassian.sal.api.net.ResponseException
import com.atlassian.sal.api.net.ResponseHandler
import groovy.json.JsonBuilder
 
/**
 * Retrieve the primary confluence application link
 * @return confluence app link
 */
def ApplicationLink getPrimaryConfluenceLink() {
    def applicationLinkService = ComponentLocator.getComponent(ApplicationLinkService.class)
    final ApplicationLink conflLink = applicationLinkService.getPrimaryApplicationLink(ConfluenceApplicationType.class);
    conflLink
}
 
// the issue provided to us in the binding
Issue issue = issue
 
// if you don't want to create confluence pages based on some criterion like issue type, handle this, eg:
//if (! issue.issueTypeObject.name == "Bug") {
//    return
//}
 
def confluenceLink = getPrimaryConfluenceLink()
assert confluenceLink // must have a working app link set up
 
def authenticatedRequestFactory = confluenceLink.createAuthenticatedRequestFactory()
 
// set the page title - this should be unique in the space or page creation will fail
def pageTitle = issue.key + " Discussion"
def pageBody = """h3. ${issue.summary}
{quote}${issue.description}{quote}
Yada yada, use this page to discuss the above...
"""
 
def params = [
    type: "page",
    title: pageTitle,
    space: [
        key: "DS" // set the space key - or calculate it from the project or something
    ],
    // if you want to specify create the page under another, do it like this:
    // ancestors: [
    //     [
    //         type: "page",
    //         id: "14123220",
    //     ]
    // ],
    body: [
        wiki: [
            value: pageBody
        ]
    ]
]
 
authenticatedRequestFactory
    .createRequest(Request.MethodType.POST, "rest/api/content")
    .addHeader("Content-Type", "application/json")
    .setRequestBody(new JsonBuilder(params).toString())
    .execute(new ResponseHandler<Response>() {
        @Override
        void handle(Response response) throws ResponseException {
            if(response.statusCode != HttpURLConnection.HTTP_OK) {
                throw new Exception(response.getResponseBodyAsString())
            }
        }
})

DS - is the key of Demo space in Confluence. But pages are not created on the issue transition. Why?

Check your logs and post anything relevant?

Hi @JamieA 

 

Can we create pages to the confluence that is not connected as primary application links

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

5,343 views 4 6
Join discussion

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