Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission issue during workflow Fast Transitions #117

Closed
joojoomen opened this issue Jun 24, 2021 · 0 comments
Closed

Permission issue during workflow Fast Transitions #117

joojoomen opened this issue Jun 24, 2021 · 0 comments

Comments

@joojoomen
Copy link

joojoomen commented Jun 24, 2021

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:

  1. 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.

  2. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant