Hello there,
I have set a global transition in my workflow.
From anywhere to anywhere, in this way i can use the transition from everywhere in my workflow.
I would like to made this transition available only for specific usergroup and projet.
I have define a Script condition threw customscript, unfortunatly it's not working.
please, find below my scrip descritpion:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.security.groups.GroupManager
import org.apache.log4j.Category
log.debug("///////////////////////DEBUT CONDITION///////////////////")
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
log.debug("user: " + user)
def componentManager = ComponentManager.getInstance()
GroupManager groupManager = ComponentManager.getComponentInstanceOfType(GroupManager.class)
String cee = "CEE"
String rso = "RSO"
log.debug("Cle projet: " + issue.getProjectObject().getKey().toString())
log.debug("user CEE? " + groupManager.isUserInGroup(user,cee))
log.debug("user rso? " + groupManager.isUserInGroup(user,rso))
log.debug("Gros test ok? " + ("CEE".equals(issue.getProjectObject().getKey().toString())) && (groupManager.isUserInGroup(user,cee) || groupManager.isUserInGroup(user,rso)))
("CEE".equals(issue.getProjectObject().getKey().toString())) && (groupManager.isUserInGroup(user,cee) || groupManager.isUserInGroup(user,rso))
I would like to be able to use this transition only if i am in CEE projet and a CEE user or RSO user.
the transition is available for all user ( not in CEE projet and not in CEE or RSO user group)
In my log file, i didin"'t reach the first log trace "///debut condition///" but the script run each time i use the transition.
Does anyone see what i am missing? i have not clue actually what i am doing wrong.
Hello @Olivier MAZEN
Is this simple scripted condition? If so, try to use lo.error instead of debug. If you want to use debug, you need to set debug level on scriptrunner package in logging and profiling.
and this script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
log.error("///////////////////////DEBUT CONDITION///////////////////")
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
log.error("user: " + user)
def groupManager = ComponentAccessor.getGroupManager()
String cee = "CEE"
String rso = "RSO"
log.error("Cle projet: " + issue.getProjectObject().getKey().toString())
log.error("user CEE? " + groupManager.isUserInGroup(user,cee))
log.error("user rso? " + groupManager.isUserInGroup(user,rso))
log.error("Gros test ok? " + ("CEE".equals(issue.getProjectObject().getKey().toString())) && (groupManager.isUserInGroup(user,cee) || groupManager.isUserInGroup(user,rso)))
("CEE".equals(issue.getProjectObject().getKey().toString())) && (groupManager.isUserInGroup(user, cee) || groupManager.isUserInGroup(user, rso))
If this is custom script condition, you should use return statement
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
log.error("///////////////////////DEBUT CONDITION///////////////////")
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
log.error("user: " + user)
def groupManager = ComponentAccessor.getGroupManager()
String cee = "CEE"
String rso = "RSO"
log.error("Cle projet: " + issue.getProjectObject().getKey().toString())
log.error("user CEE? " + groupManager.isUserInGroup(user,cee))
log.error("user rso? " + groupManager.isUserInGroup(user,rso))
log.error("Gros test ok? " + ("CEE".equals(issue.getProjectObject().getKey().toString())) && (groupManager.isUserInGroup(user,cee) || groupManager.isUserInGroup(user,rso)))
return ("CEE".equals(issue.getProjectObject().getKey().toString())) && (groupManager.isUserInGroup(user, cee) || groupManager.isUserInGroup(user, rso))
Hello Mark,
thank for your feedback, i gonna try it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello mark,
I change the code to set log level and i get a populed lgo file now.
Unfortunatly, the condition seems to not working.
please find below my news script and the log file.
as you can see i return false to the condition, but i am able to use the transition.
i dont get it:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.security.groups.GroupManager
import org.apache.log4j.Category
Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug("///////////////////////DEBUT CONDITION///////////////////")
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
log.debug("user: " + user)
GroupManager groupManager = ComponentManager.getComponentInstanceOfType(GroupManager.class)
boolean resultat = false
String cee = "CEE"
String rso = "RSO"
log.debug("PROJET? " + "CEE".equals(issue.getProjectObject().getKey().toString()))
log.debug("USER CEE? " + groupManager.isUserInGroup(user,cee))
log.debug("USER RSO? " + groupManager.isUserInGroup(user,rso))
log.debug("CEE + RSO? " + (groupManager.isUserInGroup(user,cee) || groupManager.isUserInGroup(user,rso)))
log.debug("EXECUTABLE? " + ("CEE".equals(issue.getProjectObject().getKey().toString()) && (groupManager.isUserInGroup(user,cee) || groupManager.isUserInGroup(user,rso))))
resultat = ("CEE".equals(issue.getProjectObject().getKey().toString()) && (groupManager.isUserInGroup(user,cee) || groupManager.isUserInGroup(user,rso)))
log.debug("resultat " + resultat)
return resultat
my log:
///////////////////////DEBUT CONDITION/////////////////// 2018-10-10 17:18:52,009 http-nio-8080-exec-4 DEBUG Olivier.mazen@orange.com 1038x8063x1 1kbpo8f 10.186.1.234,10.115.64.201,127.0.0.1 /secure/CommentAssignIssue!default.jspa [c.onresolve.jira.groovy] user: Olivier.mazen@orange.com(olivier mazen) 2018-10-10 17:18:52,009 http-nio-8080-exec-4 DEBUG Olivier.mazen@orange.com 1038x8063x1 1kbpo8f 10.186.1.234,10.115.64.201,127.0.0.1 /secure/CommentAssignIssue!default.jspa [c.onresolve.jira.groovy] PROJET? false 2018-10-10 17:18:52,009 http-nio-8080-exec-4 DEBUG Olivier.mazen@orange.com 1038x8063x1 1kbpo8f 10.186.1.234,10.115.64.201,127.0.0.1 /secure/CommentAssignIssue!default.jspa [c.onresolve.jira.groovy] USER CEE? true 2018-10-10 17:18:52,009 http-nio-8080-exec-4 DEBUG Olivier.mazen@orange.com 1038x8063x1 1kbpo8f 10.186.1.234,10.115.64.201,127.0.0.1 /secure/CommentAssignIssue!default.jspa [c.onresolve.jira.groovy] USER RSO? true 2018-10-10 17:18:52,009 http-nio-8080-exec-4 DEBUG Olivier.mazen@orange.com 1038x8063x1 1kbpo8f 10.186.1.234,10.115.64.201,127.0.0.1 /secure/CommentAssignIssue!default.jspa [c.onresolve.jira.groovy] CEE + RSO? true 2018-10-10 17:18:52,009 http-nio-8080-exec-4 DEBUG Olivier.mazen@orange.com 1038x8063x1 1kbpo8f 10.186.1.234,10.115.64.201,127.0.0.1 /secure/CommentAssignIssue!default.jspa [c.onresolve.jira.groovy] EXECUTABLE? false 2018-10-10 17:18:52,009 http-nio-8080-exec-4 DEBUG Olivier.mazen@orange.com 1038x8063x1 1kbpo8f 10.186.1.234,10.115.64.201,127.0.0.1 /secure/CommentAssignIssue!default.jspa [c.onresolve.jira.groovy] resultat false
i am still able to use the transition "Ajuster Criticité"
Regards,
Olivier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mark,
I try a simply test by just returning False. Nothing else just return false.
User are able to execute the transition, Does i am missing something ?
Olivier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mark,
i have found out my probleme.
Apparently, the condition of a transition is carried by a variable named "passesCondition"
I juste set the result of logicla test , and it's work like a charm.
I hope this will help someone :)
Oliiver
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How do you know the script runs if it never reaches the debut line?
Also, how can it be run? A condition works before you can even see the transition, it's not run as part of one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Nic,
When i edit the transition , in condition tab i saw a statement "No failure in last 15 time"
II assume the transition work and the application pass threw this condition.
Olivier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, that means it is a condition, as it runs before the transition even starts, to check if you have the right to use it. No failures simply means there's no errors in it, and as you're not returning anything from it, it's always going to allow the user to use the transition.
Mark has pointed out why your logging is not doing much.
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.