Skip to content

Commit

Permalink
Add option to not send the "hello!" message to non-whitelisted
Browse files Browse the repository at this point in the history
pull request submissions

This is helpful where you have multiple Jenkins jobs, all looking
at the same repository - rather than spamming the user with multiple
"Hello!" messages, you can pick one job to spam the user loudly, whilst
letting all your other jobs silently obey the build/whitelist/etc comments
  • Loading branch information
Jo Shields committed Aug 25, 2015
1 parent 0715a85 commit 5bafc13
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/org/jenkinsci/plugins/ghprb/Ghprb.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ public boolean isTriggerPhrase(String comment) {
public boolean ifOnlyTriggerPhrase() {
return trigger.getOnlyTriggerPhrase();
}

public boolean suppressTestingRequest() {
return trigger.getSuppressTestingRequest();
}

public boolean isWhitelisted(GHUser user) {
return trigger.getPermitAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class GhprbPullRequest {
if (helper.isWhitelisted(author)) {
accepted = true;
shouldRun = true;
} else {
} else if (!helper.suppressTestingRequest()) {
logger.log(Level.INFO, "Author of #{0} {1} on {2} not in whitelist!", new Object[] { id, author.getLogin(), reponame });
repo.addComment(id, GhprbTrigger.getDscp().getRequestForTestingPhrase());
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbTrigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class GhprbTrigger extends GhprbTriggerBackwardsCompatible {
private final String triggerPhrase;
private final String buildDescTemplate;
private final Boolean onlyTriggerPhrase;
private final Boolean suppressTestingRequest;
private final Boolean useGitHubHooks;
private final Boolean permitAll;
private String whitelist;
Expand Down Expand Up @@ -104,6 +105,7 @@ public GhprbTrigger(String adminlist,
String triggerPhrase,
Boolean onlyTriggerPhrase,
Boolean useGitHubHooks,
Boolean suppressTestingRequest,
Boolean permitAll,
Boolean autoCloseFailedPullRequests,
Boolean displayBuildErrorsOnDownstreamBuilds,
Expand All @@ -124,6 +126,7 @@ public GhprbTrigger(String adminlist,
this.cron = cron;
this.triggerPhrase = triggerPhrase;
this.onlyTriggerPhrase = onlyTriggerPhrase;
this.suppressTestingRequest = suppressTestingRequest;
this.useGitHubHooks = useGitHubHooks;
this.permitAll = permitAll;
this.autoCloseFailedPullRequests = autoCloseFailedPullRequests;
Expand Down Expand Up @@ -401,6 +404,10 @@ public String getTriggerPhrase() {
public Boolean getOnlyTriggerPhrase() {
return onlyTriggerPhrase != null && onlyTriggerPhrase;
}

public Boolean getSuppressTestingRequest() {
return suppressTestingRequest;
}

public Boolean getUseGitHubHooks() {
return useGitHubHooks != null && useGitHubHooks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ f.advanced() {
f.entry(field: "onlyTriggerPhrase", title: "Only use trigger phrase for build triggering") {
f.checkbox()
}
f.entry(field: "suppressTestingRequest", title: "Don't send request for approval message for non-whitelisted builders") {
f.checkbox()
}
f.entry(field: "autoCloseFailedPullRequests", title: _("Close failed pull request automatically?")) {
f.checkbox(default: descriptor.autoCloseFailedPullRequests)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<f:entry title="Only use trigger phrase for build triggering" field="onlyTriggerPhrase">
<f:checkbox />
</f:entry>
<f:entry title="Don't send request for approval message for non-whitelisted builders" field="suppressTestingRequest">
<f:checkbox />
</f:entry>
<f:entry title="${%Close failed pull request automatically?}" field="autoCloseFailedPullRequests">
<f:checkbox default="${descriptor.autoCloseFailedPullRequests}"/>
</f:entry>
Expand Down

0 comments on commit 5bafc13

Please sign in to comment.