0

How to replace text (links to network shares) in issue?

The following code does not work:

rule auto - replace reference to P drive with fully-qualified path.

when (summary.changed || description.changed || comments.added.isNotEmpty) && (becomesReported() || isReported()) {
  var shortPDrivePath = "p:\\";
  var fullPDrivePath = "\\\\myserver-depo\\projects\\";

  if (summary.contains(shortPDrivePath, opts)) {
    summary.replace(shortPDrivePath, fullPDrivePath);
  }
   
  // method 1
  if (description.indexOf(shortPDrivePath, opts) != -1) {
    description.replace(shortPDrivePath, fullPDrivePath);
    message("description updated.");
  }
   
  // method 2
  if (description.contains(shortPDrivePath, opts)) {
    description.replace(shortPDrivePath, fullPDrivePath);
    message("description updated.");
  }
   
  for each comment in comments.added {
    if (comment.text.contains(shortPDrivePath, opts)) {
      comment.text.replace(shortPDrivePath, fullPDrivePath);
    }
  }
   
  message("processed text in issue.");
}

2 comments

Please sign in to leave a comment.