Comment on linked issues post function script : how to set visibility level ?

Hi to all,

I've been using Script Runner for a few months, and I found the built-in "Update on blocking issues" script quite useful. In our implementation, on a given transition of a Dev ticket, it comments on any linked Support issue.

Now, the linked issues I'd like to comment on are seen by our clients, and so is the automatic comment. I'd like to have the visibility level of the comment set on an internal group, but the option is not given by the built-in script.

Does anyone have the script of this post function, or know if it is available for me to improve? Is there any alternative script in which I could hope to find this feature?

Regards,
Mathieu 

2 answers

Hi Thanos,

Thanks for the quick answer and the link.
It is too bad I couldn't be given access to the built-in script, as it covered already 90% of what I need ... (I don't get very much why built-in scripts should be kept secret when one has the #1 selling script plug-in for JIRA).

Anyway, it obviously is a great plugin !

Regards,
Mathieu 

PS : for whoever needs it, here's the script I got working, made from other scripts found around here as well. It's amazingly ugly and full of useless lines and imports, but it gets the job done for now ... feel free to edit a "clean" garbage-less one if needed !

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
 
def componentManager = ComponentManager.getInstance()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
 
import org.apache.log4j.Category
import com.atlassian.jira.issue.comments.CommentManager
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
  
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug "debug statements"
 
log.debug "Hello"
  
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
def currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()//
 
// Récupérer les informations de la requête client d'origine 
issueLinkManager.getInwardLinks(issue.getId())?.each {issueLink ->
    	log.debug("Checking type : "+issueLink.issueLinkType.name)
        if (issueLink.issueLinkType.name == "0.Affilier") {
        log.debug ("Linktyp: "                + issueLink.issueLinkType.name)
        log.debug ("Status parent: "      + issueLink.sourceObject.getStatus())
        log.debug ("ID parent: "              + issueLink.sourceObject.getId())
        log.debug ("Schlüssel Verlinkung: " + issueLink.sourceObject.getKey())
 
        // Seulement si la requête client est à l'état Prise en Charge / Traitement Développeurs
            log.debug("Issue link destination of type "+issueLink.getSourceObject().getClass())
            if ((issueLink.sourceObject.getStatus().getName() == "Prise en charge") || (issueLink.sourceObject.getStatus().getName() == "Traitement Développeurs") || (issueLink.sourceObject.getStatus().getName() == "Validé Club Utilisateurs")){
                
        // Lancer la transition 71 vers Traitement Développeurs
                if (issueLink.getSourceObject() instanceof MutableIssue) {
                     
        // Ajouter un commentaire
               		CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class);
                	String comment = "ATTENTION : une demande DEV affiliée à celle-ci a été fermée prématurément, pourquoi?";
                    commentManager.create(issueLink.getSourceObject(), currentUserObj, comment, null, (Long) 10001, true)//////////
 
                    }
                }
            }
else {log.debug("Hello CCCCCCCC")}
       }

nice one Mathieu...

Hi Mathieu,

You can do this but in your own custom post function. And there you can use the commentManager to set group or/and project level restrictions in your comment. If you start writing the script I can assist you further.

I would also suggest you to create a feature request for the ability to set restrictions in comments in the built in script.

regards,

Thanos 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,775 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot