Skip to content

Commit

Permalink
Fix issues caused by JENKINS-31150 not being backward compatible.
Browse files Browse the repository at this point in the history
1 - NPE thrown when tags are stored under the old format.
2 - Tags are not displayed in job configuration when reloaded under the new format.
  • Loading branch information
jringuette committed Nov 27, 2015
1 parent 20745f2 commit abf6f1d
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/main/java/org/jenkinsci/plugins/rundeck/RundeckNotifier.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;


Expand Down Expand Up @@ -69,8 +75,10 @@ public class RundeckNotifier extends Notifier {
private final String options; private final String options;


private final String nodeFilters; private final String nodeFilters;

private transient final String tag;


private final String[] tags; private String[] tags;


private final Boolean shouldWaitForRundeckJob; private final Boolean shouldWaitForRundeckJob;


Expand All @@ -93,6 +101,7 @@ public RundeckNotifier(String rundeckInstance, String jobId, String options, Str
this.options = options; this.options = options;
this.nodeFilters = nodeFilters; this.nodeFilters = nodeFilters;
this.tags = extracttags(tags,","); this.tags = extracttags(tags,",");
this.tag = null;
this.shouldWaitForRundeckJob = shouldWaitForRundeckJob; this.shouldWaitForRundeckJob = shouldWaitForRundeckJob;
this.shouldFailTheBuild = shouldFailTheBuild; this.shouldFailTheBuild = shouldFailTheBuild;
this.includeRundeckLogs = includeRundeckLogs; this.includeRundeckLogs = includeRundeckLogs;
Expand All @@ -103,6 +112,9 @@ public Object readResolve() {
if (StringUtils.isEmpty(rundeckInstance)) { if (StringUtils.isEmpty(rundeckInstance)) {
this.rundeckInstance = "Default"; this.rundeckInstance = "Default";
} }
if (tags == null) {
this.tags = extracttags(this.tag, ",");
}
return this; return this;
} }


Expand Down Expand Up @@ -392,6 +404,20 @@ public String getOptions() {
public String getNodeFilters() { public String getNodeFilters() {
return nodeFilters; return nodeFilters;
} }

public String getTag() {
StringBuilder builder = new StringBuilder();

for (int i=0; i<tags.length; i++) {
builder.append(tags[i]);

if (i+1<tags.length) {
builder.append(",");
}
}

return builder.toString();
}


public String[] getTags() { public String[] getTags() {
return tags; return tags;
Expand Down

0 comments on commit abf6f1d

Please sign in to comment.