Hi ,
I have a case where when transitioning from State Todo to In progress, I need to take a value of a field(e.g. ENV) and send a request(GET/POST) to server(e.g http://test:4000\). The server verify values and send a response(Success/Failure) message back to Jira.
Only when the message is success, the workflow should allow transition to move from Todo to In progress, else error message should display and stay in Same transition(i.e TODO).
Could you help me how to send a response(GET/POST) to server(http://test:4000\) and display message in JIRA?
Is it achievable through script in Workflow postfunction?
Please let me know the solution.
Regards,
Tamil
Hi Mathis,
With reference to link, i have created a script to REST(GET) to url, but i couldn't get response message back from the external url.
Moreover i need the message from external url to be displayed on Jira screen. how to make config to bring external url response to jira screen with pop-up message or set to field?
import groovy.json.JsonSlurper;
import groovy.json.StreamingJsonBuilder;
//import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue
import org.apache.commons.codec.binary.Base64;
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import groovyx.net.http.ContentType
import static groovyx.net.http.Method.*
import groovy.json.JsonSlurper
import net.sf.json.groovy.JsonSlurper
import groovy.json.JsonOutput
// Define Required Component Access
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
// Get field values
def region="CANADA";
def ccid="ZZZZZZ";
def user="abc@gmail.com"
def jsonBody = ["region": region,"ccid":ccid,"user":user ]
// Define Web API to post to
def baseURL = "http://test:8000/process";
// Establish Connection and post data
URL url = new URL(baseURL);
//URLConnection connection = url.openConnection();
log.error("url="+url);
HttpURLConnection connection = url.openConnection() as HttpURLConnection;
connection.requestMethod = "GET"
connection.doOutput = true
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8")
connection.outputStream
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, jsonBody) }
connection.connect();
log.error("URL="+url+"Status="+connection.getResponseCode() as String)
log.error("status1"+connection.getResponseMessage())
println("getResponseMessage:" + connection.getResponseMessage())
Hello @TAMILSELVAN V
Pretty sure it's doable, but I can't say I've tried it before.
This should help you: https://community.atlassian.com/t5/Adaptavist-questions/Making-a-REST-call-using-script-runner/qaq-p/576712
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.