Hello,
I'm trying to get the assignee and worklog by status as well.
i.e get the current assignee each time the status is changed and get the worklog if entered on the status change.
Is there a way to achieve this?
Code for getting change history and work logs:
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.history.ChangeItemBean
def customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class)
// TEsting only
Issue issue = issueManager.getIssueByCurrentKey("ACB-614")
def worklogManager = ComponentAccessor.getWorklogManager()
def statusChange = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, 'status')
def items = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, 'assignee')
def worklogs = worklogManager.getByIssue(issue)
Thank you.
Hi @Nag
For your requirement, you could try using ScriptRunner's Custom Scheduled Job.
Below is a sample code for your reference:-
import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat
def versionManager = ComponentAccessor.versionManager
def dateFormat = new SimpleDateFormat('yyyyMM')
def calendar = Calendar.instance
calendar.setTime(new Date())
calendar.add(Calendar.YEAR, 0) // current year
calendar.add(Calendar.MONTH,-1) // previous month
versionManager.allVersions.each {
if (it.name.contains(dateFormat.format(calendar.time))) {
versionManager.releaseVersion(it, true)
}
}
null
Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the configuration:-
In the sample code above, the date range is set to one month before, i.e. the previous month.
If you intend to run this every month, I suggest that versions that are older than one month be run using the ScriptRunner console first.
Alternatively, if you want to run all of it using the Scheduled Jobs, you will need to configure multiple Scheduled Jobs according to the date range.
I hope this helps to answer your question. :)
Thank you and Kind regards,
Ram
Thanks @Ram Kumar Aravindakshan _Adaptavist_
That's very quick. the solution is working as per my question.
Sorry I missed to add I'm looking to release versions only on specific list of 6 projects.
I believe it's possible that I can define them in an array. Also appreciate if there is any explanation how it's working.
It's short and simple, that helps me to learn. Thanks!
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.