|
28 | 28 | import static com.cloudbees.jenkins.Messages.GitHubCommitNotifier_DisplayName;
|
29 | 29 | import static com.cloudbees.jenkins.Messages.GitHubCommitNotifier_SettingCommitStatus;
|
30 | 30 | import static com.coravy.hudson.plugins.github.GithubProjectProperty.displayNameFor;
|
| 31 | +import static com.google.common.base.Objects.firstNonNull; |
31 | 32 | import static hudson.model.Result.FAILURE;
|
32 | 33 | import static hudson.model.Result.SUCCESS;
|
33 | 34 | import static hudson.model.Result.UNSTABLE;
|
|
41 | 42 | * @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
|
42 | 43 | */
|
43 | 44 | public class GitHubCommitNotifier extends Notifier {
|
| 45 | + private static final ExpandableMessage DEFAULT_MESSAGE = new ExpandableMessage(""); |
44 | 46 |
|
45 |
| - private ExpandableMessage statusMessage = new ExpandableMessage(""); |
| 47 | + private ExpandableMessage statusMessage = DEFAULT_MESSAGE; |
46 | 48 |
|
47 | 49 | private final String resultOnFailure;
|
48 | 50 | private static final Result[] SUPPORTED_RESULTS = {FAILURE, UNSTABLE, SUCCESS};
|
@@ -124,7 +126,8 @@ private void updateCommitStatus(@Nonnull AbstractBuild<?, ?> build,
|
124 | 126 | final String sha1 = ObjectId.toString(BuildDataHelper.getCommitSHA1(build));
|
125 | 127 |
|
126 | 128 | StatusResult status = statusFrom(build);
|
127 |
| - String message = defaultIfEmpty(statusMessage.expandAll(build, listener), status.getMsg()); |
| 129 | + String message = defaultIfEmpty(firstNonNull(statusMessage, DEFAULT_MESSAGE) |
| 130 | + .expandAll(build, listener), status.getMsg()); |
128 | 131 | String contextName = displayNameFor(build.getProject());
|
129 | 132 |
|
130 | 133 | for (GitHubRepositoryName name : GitHubRepositoryNameContributor.parseAssociatedNames(build.getProject())) {
|
|
0 commit comments