8000 [FIXES JENKINS-32132] Check status message is null (in case of wrong … by lanwen · Pull Request #103 · jenkinsci/github-plugin · GitHub
[go: up one dir, main page]

Skip to content

[FIXES JENKINS-32132] Check status message is null (in case of wrong … #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static com.cloudbees.jenkins.Messages.GitHubCommitNotifier_DisplayName;
import static com.cloudbees.jenkins.Messages.GitHubCommitNotifier_SettingCommitStatus;
import static com.coravy.hudson.plugins.github.GithubProjectProperty.displayNameFor;
import static com.google.common.base.Objects.firstNonNull;
import static hudson.model.Result.FAILURE;
import static hudson.model.Result.SUCCESS;
import static hudson.model.Result.UNSTABLE;
Expand All @@ -41,8 +42,9 @@
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
*/
public class GitHubCommitNotifier extends Notifier {
private static final ExpandableMessage DEFAULT_MESSAGE = new ExpandableMessage("");

private ExpandableMessage statusMessage = new ExpandableMessage("");
private ExpandableMessage statusMessage = DEFAULT_MESSAGE;

private final String resultOnFailure;
private static final Result[] SUPPORTED_RESULTS = {FAILURE, UNSTABLE, SUCCESS};
Expand Down Expand Up @@ -124,7 +126,8 @@ private void updateCommitStatus(@Nonnull AbstractBuild<?, ?> build,
final String sha1 = ObjectId.toString(BuildDataHelper.getCommitSHA1(build));

StatusResult status = statusFrom(build);
String message = defaultIfEmpty(statusMessage.expandAll(build, listener), status.getMsg());
String message = defaultIfEmpty(firstNonNull(statusMessage, DEFAULT_MESSAGE)
.expandAll(build, listener), status.getMsg());
String contextName = displayNameFor(build.getProject());

for (GitHubRepositoryName name : GitHubRepositoryNameContributor.parseAssociatedNames(build.getProject())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

import static com.cloudbees.jenkins.Messages.GitHubCommitNotifier_SettingCommitStatus;
import static com.coravy.hudson.plugins.github.GithubProjectProperty.displayNameFor;
import static com.google.common.base.Objects.firstNonNull;
import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;

@Extension
public class GitHubSetCommitStatusBuilder extends Builder {
private ExpandableMessage statusMessage = new ExpandableMessage("");
private static final ExpandableMessage DEFAULT_MESSAGE = new ExpandableMessage("");

private ExpandableMessage statusMessage = DEFAULT_MESSAGE;

@DataBoundConstructor
public GitHubSetCommitStatusBuilder() {
Expand All @@ -50,7 +53,7 @@ public boolean perform(AbstractBuild<?, ?> build,
BuildListener listener) throws InterruptedException, IOException {
final String sha1 = ObjectId.toString(BuildDataHelper.getCommitSHA1(build));
String message = defaultIfEmpty(
statusMessage.expandAll(build, listener),
firstNonNull(statusMessage, DEFAULT_MESSAGE).expandAll(build, listener),
Messages.CommitNotifier_Pending(build.getDisplayName())
);
String contextName = displayNameFor(build.getProject());
Expand Down
0