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!
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.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}")
}
}
})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.