Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Create Jira Tickets Based off of File List in Confluence

Rob January 15, 2021

I have Confluence and Jira Server linked together in application links. All of the normal integrations work just fine.

What I am looking for (might be wishing on a star here), is if there is an option/integration that would allow a user to drop a document in a File List in confluence and have that upload trigger a ticket getting created in Jira?

Or even if it was something like upload a file, click a button. And then a jira ticket would be created with a link to the newly uploaded file.

Any thoughts are welcomed!

Thanks!

1 answer

1 accepted

0 votes
Answer accepted
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2021

Hi @Rob ,

I can imagine doing it using ScriptRunner for Confluence. You can create custom script listener - there's AttachmentCreateEvent you can react on, but it will take some groovy programming.

Should the issue always be created to the specific project, or it will differ based on the space?

I've searched through marketplace and even though there are some applications, which enables you to create Jira issues easily, I didn't find any, which will do it based on the attachment.

Rob January 19, 2021

Thanks for the response Hana!

Yes, the issue would always be created in the same Jira project and triggered from the same space in Confluence.

I am not a programmer at heart. But I can sure delve in and see what I can find out. Maybe there are some snippets out on the web somewhere I can grab pieces of groovy to make it work.

Thank you!

Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 19, 2021

Hi @Rob ,

hopefully something like this will work for you - I just tested it and I was able to create the issue based on attachment creation. I got inspiration here. Please also change the parameters like project key and issue type before testing :-).

import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.jira.JiraApplicationType
import com.atlassian.confluence.event.events.content.attachment.AttachmentCreateEvent
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 groovy.json.JsonBuilder
import static com.atlassian.sal.api.net.Request.MethodType.POST

def event = event as AttachmentCreateEvent

def appLinkService = ComponentLocator.getComponent(ApplicationLinkService)
def appLink = appLinkService.getPrimaryApplicationLink(JiraApplicationType)
def applicationLinkRequestFactory = appLink.createAuthenticatedRequestFactory()
def attachment = event.getAttachment()

def body = new JsonBuilder([
fields: [
project : [key: "XXX"],
summary : "Confluence Attachment Created - " + attachment.getFileName(),
description: "Test description",
issuetype : [name: "Task"]
]
]).toString()

def request = applicationLinkRequestFactory.createRequest(POST, "/rest/api/2/issue")
.addHeader("Content-Type", "application/json")
.setEntity(body)

request.execute(new ResponseHandler<Response>() {
@Override
void handle(Response response) throws ResponseException {
if (response.statusCode != 201) {
log.error("Creating Jira issue failed: ${response.responseBodyAsString}")
}
}
})
Rob January 19, 2021

Wow, thank you very much @Hana Kučerová !

I'll get everything setup (currently am not using ScriptRunner for Confluence, so will need to get that installed and setup) and test it out.

Thank you for working that up so fast!

Like Hana Kučerová likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.8.0
TAGS
AUG Leaders

Atlassian Community Events