Hi Team,
is it possible to get some details of issues on Jira data center running groovy script on Jira cloud instance?
Hi Chamadri,
It is possible to achieve this requirement with ScriptRunner for Jira Cloud.
I don't have an example script on how to do this, but you will need to use the Jira Data Center rest APIs and call these from your script.
You would need to use the Get Issue for Key API and call this from within ScriptRunner for Jira Cloud, providing credentials to authenticate with the data centre instance.
ScriptRunner for Jira Cloud uses Unirest to make rest API calls and you can see an example request for calling an external API here to give an example of the structure to use.
Hope this helps.
Regards,
Kristian
This simple script should be helpful :)
import groovy.json.JsonSlurper
import java.net.HttpURLConnection
import java.net.URL
// Jira Data Center URL
def jiraUrl = "<https://your-jira-data-center-instance.com>"
// Endpoint you want to connect to
def apiEndpoint = "/rest/api/2/issue/CRE-12345"
// Construct full URL
def fullUrl = new URL(jiraUrl + apiEndpoint)
// Set up connection
def connection = (HttpURLConnection) fullUrl.openConnection()
connection.setRequestMethod("GET")
// connection.setRequestProperty("Authorization", "Basic " + "YOUR_BASE64_ENCODED_AUTH_STRING")
// Alternatively, use an API token
connection.setRequestProperty("Authorization", "Bearer YOUR_API_TOKEN")
// Execute the request
def responseCode = connection.getResponseCode()
println "Response Code : $responseCode"
if(responseCode == HttpURLConnection.HTTP_OK) {
def response = new JsonSlurper().parse(new InputStreamReader(connection.getInputStream()))
println "Response: $response"
} else {
println "Failed to connect: $responseCode"
}
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.