Skip to content

Commit

Permalink
JENKINS-31150 - supporting multiple coma separated scm tags, aded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yurigo79 committed Oct 24, 2015
1 parent 3ddad7c commit b20a96e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/org/jenkinsci/plugins/rundeck/RundeckNotifier.java
Expand Up @@ -635,9 +635,17 @@ private String[] extracttags(String tagsStr, String delimiter){

if (tagsStr == null)
return new String[0];

List<String> list = new ArrayList<String>(Arrays.asList(tagsStr.split(delimiter)));
list.removeAll(Collections.singleton(""));

for (ListIterator<String> iterator = list.listIterator(); iterator.hasNext(); ) {
String tag = iterator.next();
tag=tag.replaceAll("\\s+","").trim();
iterator.remove();
if (!tag.equals(""))
iterator.add(tag);

}

return list.toArray(new String[list.size()]);
}

Expand Down
Expand Up @@ -7,6 +7,8 @@
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Date;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -284,6 +286,32 @@ public void testWaitForRundeckJob() throws Exception {
}


public void testGetTags(){

RundeckNotifier notifier;
String[] tags;

notifier = new RundeckNotifier("1", null, null, "#deploy", false, true);
tags= new String[] {"#deploy"};
assertTrue(Arrays.equals(tags, notifier.getTags()));

notifier = new RundeckNotifier("1", null, null, null, false, true);
tags= new String[0];
assertTrue(Arrays.equals(tags, notifier.getTags()));

notifier = new RundeckNotifier("1", null, null, "", false, true);
tags= new String[0];
assertTrue(Arrays.equals(tags, notifier.getTags()));

notifier = new RundeckNotifier("1", null, null, " ", false, true);
tags= new String[0];
assertTrue(Arrays.equals(tags, notifier.getTags()));

notifier = new RundeckNotifier("1", null, null, "#tag1, #tag2", false, true);
tags= new String[] {"#tag1", "#tag2"};
assertTrue(Arrays.equals(tags, notifier.getTags()));

}


private String createOptions() {
Expand Down

0 comments on commit b20a96e

Please sign in to comment.