Skip to content

Commit

Permalink
Fix #62 by excluding empty affected files collection
Browse files Browse the repository at this point in the history
Jenkins Repo plugin adds an "empty" change log when there is a
new project added or removed, e.g.:

path: local/path
serverPath: server/path
revision: null
authorName: null
authorEmail: null
authorDate: null
committerName: null
committerEmail: null
committerDate: null
commitText: This project was added from the manifest.
modifiedFiles: null

When Slack plugin tries to add the "null" affected files, it gets a
NullPointerException error.

Fix the error by not adding any empty affected files collection.
  • Loading branch information
yestin committed Mar 19, 2016
1 parent ae8e6e3 commit 0c6b4a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/jenkins/plugins/slack/ActiveNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import hudson.tasks.test.AbstractTestResultAction;
import hudson.triggers.SCMTrigger;
import hudson.util.LogTaskListener;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;

import java.io.IOException;
Expand Down Expand Up @@ -128,7 +129,9 @@ String getChanges(AbstractBuild r, boolean includeCustomMessage) {
Entry entry = (Entry) o;
logger.info("Entry " + o);
entries.add(entry);
files.addAll(entry.getAffectedFiles());
if (CollectionUtils.isNotEmpty(entry.getAffectedFiles())) {
files.addAll(entry.getAffectedFiles());
}
}
if (entries.isEmpty()) {
logger.info("Empty change...");
Expand Down

0 comments on commit 0c6b4a7

Please sign in to comment.