Hi,
My requirement is to create a macro in confluence using script-runner to get the jira version. I am getting getting error while executing the below script in script-runner console page in confluence.
unable to resolve class com.atlassian.sal.api.net.RequestFactory
unable to resolve class com.atlassian.jira.component.ComponentAccessor
import groovy.json.JsonSlurper
import com.atlassian.sal.api.net.RequestFactory
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.util.BuildUtilsInfo
def jiraBaseUrl = "https://server-hostname"
def jiraApiPath = "/rest/api/2/serverInfo"
/*def requestfact = new RequestFactory()
def response = requestfact.createRequest()
.setMethod("GET")
.setUrl("${jiraBaseUrl}${jiraApiPath}")
.execute()
// Parse the response JSON
def jsonResponse = new JsonSlurper().parseText(response.getResponseBodyAsString()) */
def jiraVersion = jsonResponse.version
def jiraBuildNo = jsonResponse.buildNumber
def jiraBuildDate = jsonResponse.buildDate
log.info("Jira Version: ${jiraVersion}")
log.info("Jira BuildNo: ${jiraBuildNo}")
log.info("Jira BuildDate: ${jiraBuildDate}")
Thanks
Arun
Hi @Arunkumar Duraimani welcome to the community. As mentioned it would help a great deal to finding a solution if we know the error. Please provide the error message that you are getting.
Hi Craig,
I am getting the below error.
unable to resolve class com.atlassian.sal.api.net.RequestFactory
at line: 2, column: 1
unable to resolve class com.atlassian.jira.component.ComponentAccessor
at line: 3, column: 1
unable to resolve class com.atlassian.jira.util.BuildUtilsInfo
thanks
Arunkumar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the Atlassian Community!
What error are you getting?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
I am getting the below error.
unable to resolve class com.atlassian.sal.api.net.RequestFactory
at line: 2, column: 1
unable to resolve class com.atlassian.jira.component.ComponentAccessor
at line: 3, column: 1
unable to resolve class com.atlassian.jira.util.BuildUtilsInfo
thanks
Arunkumar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Confluence does not have those classes in it. You need to be coding for Confluence to make REST calls, not Jira.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
Can i check the confluence java api to fetch the jira version.
Thanks
Arunkumar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is not going to work. You cannot "fetch the Jira version".
I do not think you understand quite what the structure here is. Jira and Confluence are separate systems, and have very different APIs because they do different things. Jira's API works primarily with issues, Confluence with pages.
Confluence does not have an API for working with issues and Jira does not have an API for working with pages.
What you've got is a load of imports for Jira, followed by some code that (at a glance) is system-agnostic - you could run it from anything and it would try to read Jira's REST data into the variables.
All you need to import are the classes required to support REST calls.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Today only! Share what you’re the most excited about for Team ‘25 or just dance out the beginning of a new quarter with us.
Comment the postOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.