We have implemented a scheduled task to transition some task into a close state for some conditions using the fast transition example from the global object class.
The transition works but we have two problems:
The transition works only if the job is running as user with jira admin permission. Also if the user who should to this is permitted and can make the transition using the GUI.
We want to log the affected task. But if some task was transitioned no log will be there. Find the code below
import com.atlassian.jira.issue.*
import com.atlassian.jira.user.ApplicationUser
import groovy.sql.GroovyRowResult
import org.codehaus.groovy.runtime.StackTraceUtils
import com.atlassian.jira.component.ComponentAccessor
Date today=new Date()
Date lastdate
ApplicationUser pima = Base.getUser('jiraadmin')
String query=sqlstr.getText('UTF-8')
String countertemplquery="SELECT COUNT(id) AS counter,MAX (date_create) AS lastnotification FROM customer_issue_notifications WHERE issue='%ISSUE%' AND notification_type='close_umsetzungsauftrag'"
String counterquery
List result=Base.select('jiraDB',query)
if(result.size()==0){
log.info("Nothing to do")
return true;
}
Hey there.
We have implemented a scheduled task to transition some task into a close state for some conditions using the fast transition example from the global object class. The transition works but we have two problems:
The transition works only if the job is running as user with jira admin permission. Also if the user who should to this is permitted and can make the transition using the GUI.
We want to log the affected task. But if some task was transitioned no log will be there. Find the code below
if(DateFunc.isWorkingDay(today)==false){ return true }
log.info("Start Cancle Implementation.") def sqlstr=new File("FilePath") if(sqlstr==null){ log.info("Unable to load sql filel") return false; } HashMap map
ApplicationUser pima = Base.getUser('jiraadmin') String query=sqlstr.getText('UTF-8') String countertemplquery="SELECT COUNT(id) AS counter,MAX (date_create) AS lastnotification FROM customer_issue_notifications WHERE issue='%ISSUE%' AND notification_type='close_umsetzungsauftrag'" String counterquery List result=Base.select('jiraDB',query) if(result.size()==0){ log.info("Nothing to do") return true; }
Issue issue MutableIssue parentIssue ApplicationUser assignee
String key
GroovyRowResult sendDone Long count Integer actionId = 41 // The transition ID
try{ result.each{item ->
key=item['issue'].toString() issue=Base.getIssue(key) parentIssue=issue.getParentObject() as MutableIssue counterquery=countertemplquery.replaceAll("%ISSUE%",key) sendDone=Base.SqlGetRow("serviceDB",counterquery)
lastdate = Date.parse("yyyy-MM-dd hh:mm:ss", sendDone.lastnotification.toString())
count=sendDone.counter as Long if(count==4){
}
}catch(Exception ex) { log.error(ex.toString()+"=>"+ex.stackTrace.head().lineNumber) return false }
log.info("Done Cancle Implementation") return true