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.JsonSlurperimport java.net.HttpURLConnectionimport java.net.URL// Jira Data Center URLdef jiraUrl = "<https://your-jira-data-center-instance.com>"// Endpoint you want to connect todef apiEndpoint = "/rest/api/2/issue/CRE-12345"// Construct full URLdef fullUrl = new URL(jiraUrl + apiEndpoint)// Set up connectiondef connection = (HttpURLConnection) fullUrl.openConnection()connection.setRequestMethod("GET")// connection.setRequestProperty("Authorization", "Basic " + "YOUR_BASE64_ENCODED_AUTH_STRING")// Alternatively, use an API tokenconnection.setRequestProperty("Authorization", "Bearer YOUR_API_TOKEN")// Execute the requestdef 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"}
It looks like you're new here. Sign in or register to get started.