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
On my environment everything works fine.

Set the test issue description to "p:\" and try to execute this simple rule:
rule test 
 
when Priority.changed { 
  var str = "p:\\"; 
  message(description.contains(str, opts) + "; " + description.indexOf(str, opts)); 
  summary = summary.replace("a", "b"); 
}
prettyPrint();
Does the message show 'true' and еру correct index? Do the 'a' letters are replaced with 'b' in the summary?
0

Please sign in to leave a comment.