How to make global changes to comments (JCLI)

Description

Suppose you want to modify all issue comments to change a URL or some other text to something else. Can this be done without scripting? Yes, this page will show you the techniques for how this can be done. Don't let the double-quote escaping throw you off (wink).

Be specific

Whenever you use find replace logic, be as specific as possible in defining your find string so that you don't get unexpected replacements! Especially important when using regular expressions. Always test your regular expressions!

Details

  • We use 2 levels of run actions to get all the comments for all the issues found by the JQL query. 
  • We use the @commentBody@ special value to indicate that we want the find-replace logic to be applied to the existing comment body to set the updated comment.
  • We use the findReplace parameter in this simple case. You can also use the findReplaceRegex parameter similarly for more complex cases.
--action runFromIssueList --jql "project in (JCLI)" --common "-a runFromCommentList --issue @issue@ --common \"-a updateComment --issue @issue@ --id @commentId@ --comment @commentBody@ --findReplace \"\"old.examplegear.com:new.examplegear.com\"\" \" "