hi,
we have a scriptrunner custom endpoint which returns our worklogs and worklog-issue-data. as soons as we start to add customfield-informations our script crashes and returns:
{"message":null,"stack-trace":"java.lang.StackOverflowError\n","status-code":"INTERNAL_SERVER_ERROR"}
we tried to fire this script in the scriptrunner cosnole but we are not running into any errors there. did anyone experience similiar issues or might have a solotion to this?
this is the full script:
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.worklog.Worklog
@BaseScript CustomEndpointDelegate delegate
getIssueWorklogs(httpMethod: "GET", groups: []) { MultivaluedMap queryParams, String body ->
def worklogs = getAllWorklogs()
return Response.ok(new JsonBuilder(worklogs).toString()).build();
}
def getAllWorklogs(){
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()
ApplicationUser user = ComponentAccessor.getUserManager()getUserByName("sth")
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(user)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cfKunde = customFieldManager.getCustomFieldObject(10325)
def workLogManager = ComponentAccessor.getWorklogManager()
def query = jqlQueryParser.parseQuery("project = sth")
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
log.warn("Total issues: ${results.total}")
def issueWorklogs = [:]
results.getIssues().each {documentIssue ->
log.debug(documentIssue.key)
// if you need a mutable issue you can do:
def issue = issueManager.getIssueObject(documentIssue.id) // TODO handle exception https://docs.atlassian.com/software/jira/docs/api/7.10.2/com/atlassian/jira/issue/IssueManager.html#getIssueObject-java.lang.Long-
//get worklogs for issue
def logsForIssue = workLogManager.getByIssue(issue)
def worklogAuthor = "N/A"
def worklogTimeSpentInMinutes = "N/A"
def worklogCreatedDate = "N/A"
if(logsForIssue.size() > 0){
def worklogs = []
//assignee
def assignee
if(issue.getAssigneeUser() == null){
assignee = "unassigned"
} else {
assignee = issue.getAssigneeUser().getDisplayName()
}
def cfKundenValue = issue.getCustomFieldValue(cfKunde) //ADDING THIS CAUSES CRASH
for(Worklog worklog : logsForIssue ){
worklogAuthor = worklog.getAuthorObject().getDisplayName()
worklogTimeSpentInMinutes = worklog.getTimeSpent()/60
worklogCreatedDate = worklog.getCreated().toString()
def worklogContent = [
'Issue key': issue.getKey(),
'Issue Type': issue.getIssueType().getName(),
'Status': issue.getStatus().getName(),
'Summary, ': issue.getSummary(),
'Project key': issue.getProjectObject().getKey(),
//'Project name': issue.,
//'Project lead': issue.,
'Kunde': cfKundenValue,
'Assignee': assignee,
'Created': issue.getCreated(),
'Updated': issue.getUpdated(),
'Due Date': issue.getDueDate(),
'Original Estimate': issue.getOriginalEstimate(),
'Time Spent in s': issue.getTimeSpent(),
"WorkLogCreatedDate": worklogCreatedDate,
"WorkLogAuthor": worklogAuthor,
"WorkLogTimeSpentInMinutes": worklogTimeSpentInMinutes,
]
worklogs.push(worklogContent)
}
issueWorklogs.put(issue.getKey(), worklogs)
}
}
return issueWorklogs
}
This statement
def cfKunde = customFieldManager.getCustomFieldObject(10325)
I would expect to be
def cfKunde = customFieldManager.getCustomFieldObject("customfield_10325")
Next i would log the value returned by issue.getCustomFieldValue to check its returned.
Could also put a try/catch block around the statement to catch any unchecked exceptions.
Are there any permissions issue to do with the field? Are the callers of the rest endpoint permission differently to yourselves running in the console.
Online 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.