I couldn't edit my original question to be more clear, so I am rewording it as a new question.
I am experimenting with script runner in a post function in one of my projects. I want to get a dump of all fields of theissue , which I can then pass to an external too for some processing.
I know I can do something like this:
def curl = "/usr/bin/curl -u foo:bar http://jira.example.com:8080/jira/rest/api/latest/issue/BLAH-100.json" def output = curl.execute().text
This does give me a variable ($output) containing populated fields for the issue that I can plug into a bash script I have on the server for parsing, etc.
However, I am trying to see if I can do something similar from straight within groovy, without a call to some external tool.
Any advice? I am a groovy noob, so if you have any examples, please let me know. I have some examples online, but they seem to call libraries that I don't have (guessing they were written for stand alone groovy, and not script runner..?)
Community moderators have prevented the ability to post new answers.
Can any one show how to send post request with data to JIRA to update or insert issue from Java client.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
do you have any idea why this is not working with -X PUT? GET is working fine...
def curl = "/usr/bin/curl -u FECRU_CREDENTIALS -H Content-Type:application/json -H Accept:application/json -X PUT -d FECRU_DATA FECRU_REST_API"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is probably a better way to go about this, but I ended up doing the folowing to get system and custom field data:
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.issue.Issue; // gets a reference to the IssueManager and CustomFieldManager manager classes IssueManager issueManager = ComponentManager.getInstance().getIssueManager(); CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); // gets a reference to the desired issue and custom field Issue issue = issueManager.getIssueObject( "FOOBAR-100" ); def cflist = customFieldManager.getCustomFieldObjects(issue); def map = new HashMap<String,String>() cflist.each {cf -> Object value = issue.getCustomFieldValue(cf) map << [(cf):"$value"] } def systemfields = issueManager.getIssue ("FOOBAR-100") //getting GenericObject since it seems to contain issue fields map << systemfields // left-shift systemfields map into map to create consolidated map //Example showing line by line output: map.each{ k, v -> println "${k}::${v}" }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.