Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Responding to Confluence Events in Jira

At a recent ScriptRunner Champion Hour, I talked about how to respond to events in Confluence to update Jira.

The path we demonstrated was to use a combination of an Event Listener in Confluence and REST Endpoint in Jira. The details of using the App Links API are detailed in our documentation for ScriptRunner for Confluence (and for ScriptRunner for Jira, if you need to go the other direction). Here is the code I used.

The basic idea is that if a page in Confluence has a Jira Issue macro in it, then when someone likes that page, they should also automatically vote for the corresponding issue in Jira. Complexities like handling multiple issue macros or doing completely different operations in Jira & Confluence are left as exercises to the reader. :)

Set up a listener in ScriptRunner for Confluence

import com.atlassian.applinks.api.ApplicationLinkResponseHandler
import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.jira.JiraApplicationType
import com.atlassian.sal.api.component.ComponentLocator
import groovy.json.JsonSlurper

LikeEvent event = event
def content = event.content

def xmlStorageFormat = content.bodyAsString
def document = new XmlSlurper(false, false)
    .declareNamespace([ac: ""])

def macros = document.'ac:structured-macro'
def issueKey = macros.children().find { element ->
    element.'@ac:name' == "key"

log.debug "Found link to issue key ${issueKey} in page ${content.title}"

if (issueKey) {
    For more details on using the App Links API, see
    def appLinkService = ComponentLocator.getComponent(ApplicationLinkService)
    def appLink = appLinkService.getPrimaryApplicationLink(JiraApplicationType)
    def applicationLinkRequestFactory = appLink.createAuthenticatedRequestFactory()
    def request = applicationLinkRequestFactory.createRequest(

    def handler = new ApplicationLinkResponseHandler() {
        Map credentialsRequired(Response response) throws ResponseException {
            return null

        Map handle(Response response) throws ResponseException {
            assert response.statusCode == 200
            new JsonSlurper().parseText(response.getResponseBodyAsString()) as Map


Then a REST Endpoint in Jira:

import com.atlassian.jira.component.ComponentAccessor
import groovy.transform.BaseScript


CustomEndpointDelegate customEndpointDelegate

    httpMethod: 'PUT',
    groups: ['jira-software-users']
) { MultivaluedMap queryParams ->
    def voteManager = ComponentAccessor.voteManager
    def issueService = ComponentAccessor.issueService
    def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
    def issueKey = queryParams.getFirst('issueKey')?.toString()
    def issue = issueService.getIssue(loggedInUser, issueKey).getIssue()
    voteManager.addVote(loggedInUser, issue)

    return Response.ok("Successfully voted for issue ${issueKey}").build()




Log in or Sign up to comment
Community showcase
Published in Confluence

🥓🙅🏻‍♀️ Meet-less May Badge!

Hello Confluence Community!  What if i told you that you could have a healthier life and be 100% meet-less? This month, we're promoting a healthy, balanced work diet with Confluence. (Read m...

349 views 3 18
Read article

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