How do I import Confluence classes into JIRA ScriptRunner?

Whewnever I try to include and import classes for Confleunce, they are not recognized. The following statements are not recogized when using ScriptRunner for JIRA. I want to update a Confleuce page from JIRA.

import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.core.DefaultSaveContext


1 answer

1 accepted

0 vote

That's because the stuff you are trying to import in JIRA is not there.  JIRA doesn't need Confluence libraries because it's not Confluence.

To update a Confluence page from JIRA, write scripts that use the REST interface to update Confluence remotely.

Thanks. I've written the REST portion to get the info. Now just need to figure out how to enable the script event. For some reason it's not firing."eWebRequest Form Event Fired")   import import com.atlassian.confluence.spaces.Space import com.atlassian.confluence.pages.Page   def event = event as PageEvent   Page page = event.getPage() Space space = page.getSpace()   if (page.getSpace() != 'eWebProjects') {"eWebRequest Form Event  - 1")     return }   // Is the page-type eWebRequest? import com.atlassian.applinks.api.ApplicationLink import com.atlassian.applinks.api.ApplicationLinkService import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType import com.atlassian.sal.api.component.ComponentLocator import import import import import import groovy.json.JsonBuilder   //import com.atlassian.confluence.pages.CommentManager   def ApplicationLink getPrimaryConfluenceLink() {     def applicationLinkService = ComponentLocator.getComponent(ApplicationLinkService.class)     final ApplicationLink conflLink = applicationLinkService.getPrimaryApplicationLink(ConfluenceApplicationType.class);     conflLink }   def confluenceLink = getPrimaryConfluenceLink() assert confluenceLink // must have a working app link set up   def authenticatedRequestFactory = confluenceLink.createAuthenticatedRequestFactory()   // Get create content response body as a map def contentResponse = authenticatedRequestFactory         .createRequest(Request.MethodType.POST, "rest/api/content/" + + "/page-type?")         .addHeader("Content-Type", "application/json")         .executeAndReturn(new ReturningResponseHandler<Response, Map>(){     @Override     Map handle(Response response) throws ResponseException {         if (response.statusCode == HttpURLConnection.HTTP_NOT_FOUND)         {   "eWebRequest Form Event  - 2")             return         }                 if (response.statusCode != HttpURLConnection.HTTP_OK) {   "eWebRequest Form Event  - 3")             throw new Exception("Get page-type failed: " + response.getResponseBodyAsString())         }           return response.getEntity(Map)     } })   if (contentResponse.value != 'eWebRequest') {"eWebRequest Form Event  - 4")     return }   // TESTING ONLY"eWebRequest Form Event Success")

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

839 views 2 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you