addComment

    Signature

    Helper commentHelper
    Signature
    addComment(String body,  List comments )
    
    or
    
    addComment(String body, Boolean sync, List comments )
    Description


    Allows adding a custom made comment to an issue. You can specify if this comment needs to be synced or not.

    Introduced in 0.10

    Usage

    The addComment is a utility function that helps to do the following action on a comment:

    • create a comment with the comment body set directly in the sync rules
    • set the body to the provided function argument

    The author of the comment is the proxy user. If the body argument is empty, the comment is not synchronized.

    Example use

    Incoming sync

    Add a comment with the following text to an issue "Resolution changed to done" . The added comment is synced to the remote side.

    issue.comments = commentHelper.addComment("Resolution changed to done", issue.comments)

    Usually, this method is used in combination with a condition block, for example :

    Add a comment with the following text "Resolution changed to done" if the remote issue status is Done. Otherwise, sync comments in-between.

    The added comment is synced to the remote side.

    if (replica.status = "Done")  {
       issue.comments = commentHelper.addComment("Resolution changed to done", issue.comments)
    } else {
      issue.comments     = commentHelper.mergeComments(issue, replica)
    }

    Don't sync the added comment to the remote side

    Add a comment to the issue and don't sync it to the remote side using the sync parameter

    issue.comments = commentHelper.addComment("Custom made comment", false, issue.comments)