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
directhex committed Jun 1, 2015
1 parent d586a93 commit c6ccdb5
Show file tree
Hide file tree
Showing 4 changed files with 15 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 @@ -139,6 +139,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 @@ -80,7 +80,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 @@ -55,6 +55,7 @@ public class GhprbTrigger extends GhprbTriggerBackwardsCompatible {
private final String cron;
private final String triggerPhrase;
private final Boolean onlyTriggerPhrase;
private final Boolean suppressTestingRequest;
private final Boolean useGitHubHooks;
private final Boolean permitAll;
private String whitelist;
Expand Down Expand Up @@ -87,6 +88,7 @@ public GhprbTrigger(String adminlist,
String cron,
String triggerPhrase,
Boolean onlyTriggerPhrase,
Boolean suppressTestingRequest,
Boolean useGitHubHooks,
Boolean permitAll,
Boolean autoCloseFailedPullRequests,
Expand All @@ -106,6 +108,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 @@ -321,6 +324,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 @@ -12,6 +12,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 c6ccdb5

Please sign in to comment.