groovy scripting help

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

Hello

I am trying to write a script to get time when an issue was set to “in-progress”? 

I am getting an error 

Error

This resource requires WebSudo.

Here is the code, can you please let me know.

Thanks

Abe

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.builder.JqlClauseBuilder
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.project.Project
  
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def projectManager = ComponentAccessor.getProjectManager()
import org.apache.log4j.Category
def Category log = Category.getInstance("com.samsung.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
Project project = ComponentAccessor.getProjectManager().getProjectObjByKey("INFR");
CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("");
 
IssueManager issueManager = ComponentAccessor.getIssueManager();
 
for(Issue issue: issueManager.getIssueObjects( issueManager.getIssueIdsForProject(project.getId()))){
    log.debug(changeHistoryManager.getChangeItemsForField(issue, "status").find {it.toString == "In Progress"}?.getCreated())
}

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 7, 2016

It's not the code that is a problem, it's how you're running it.  How is this being run?

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

Just going to script console, pasting this code and click run button. Is there any other way, please let me know.

 

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

Just going to script console, pasting this code and click run button. Is there any other way, please let me know.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 7, 2016

No, it's a valid way to run it, we just needed to know so we didn't make incorrect assumptions.

The websudo prompt is there for security - it times out an admin after a while to stop bad people "borrowing" the admin session.

I suspect it's still running the script, just your session times out before it finishes

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

Thanks you are rigt, session timed out

Suggest an answer

Log in or Sign up to answer