You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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){
if(DateFunc.daysBetween(lastdate,today)>=7){
try{
Base.doTransition(parentIssue,actionId)
Base.reIndex(parentIssue)
Base.createComment((Issue)parentIssue,pima,'SW-Deployment wurde nach Ablauf der Frist automatisch storniert.',true)
log.info("Cancle Task "+parentIssue.key)
}catch(RuntimeException rex) {
log.info(rex.toString()+"=>"+rex.stackTrace.head().lineNumber)
}
catch(Exception ex) {
log.info(ex.toString()+"=>"+ex.stackTrace.head().lineNumber)
}
}
}
}
}catch(Exception ex) {
log.error(ex.toString()+"=>"+ex.stackTrace.head().lineNumber)
return false
}
log.info("Done Cancle Implementation")
return true
Would be nice if we can find a solution
Regards
Hannes
The text was updated successfully, but these errors were encountered:
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
Would be nice if we can find a solution
Regards
Hannes
The text was updated successfully, but these errors were encountered: