Skip to content

Commit 0955e34

Browse files
authored
Merge pull request #763 from hansson/master
Adding branches_to_be_notified to SlackService
2 parents a7991dd + 18ecca3 commit 0955e34

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/main/java/org/gitlab4j/api/services/EmailOnPushService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class EmailOnPushService extends NotificationService {
99
public static final String RECIPIENT_PROP = "recipients";
1010
public static final String DISABLE_DIFFS_PROP = "disable_diffs";
1111
public static final String SEND_FROM_COMMITTER_EMAIL_PROP = "send_from_committer_email";
12-
public static final String BRANCHES_TO_BE_NOTIFIED_PROP = "branches_to_be_notified";
1312

1413
@Override
1514
public GitLabApiForm servicePropertiesForm() {

src/main/java/org/gitlab4j/api/services/NotificationService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public abstract class NotificationService {
1313

1414
public static final String NOTIFY_ONLY_BROKEN_PIPELINES_PROP = "notify_only_broken_pipelines";
1515
public static final String NOTIFY_ONLY_DEFAULT_BRANCH_PROP = "notify_only_default_branch";
16+
public static final String BRANCHES_TO_BE_NOTIFIED_PROP = "branches_to_be_notified";
1617
public static final String PUSH_CHANNEL_PROP = "push_channel";
1718
public static final String ISSUE_CHANNEL_PROP = "issue_channel";
1819
public static final String CONFIDENTIAL_ISSUE_CHANNEL_PROP = "confidential_issue_channel";

src/main/java/org/gitlab4j/api/services/SlackService.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,50 @@ public SlackService withNotifyOnlyBrokenPipelines(Boolean notifyOnlyBrokenPipeli
139139
}
140140

141141
@JsonIgnore
142+
@Deprecated
142143
public Boolean getNotifyOnlyDefaultBranch() {
143144
return ((Boolean) getProperty(NOTIFY_ONLY_DEFAULT_BRANCH_PROP, Boolean.FALSE));
144145
}
145146

147+
/**
148+
* @deprecated use {@link SlackService#setBranchesToBeNotified(BranchesToBeNotified)}
149+
* @param notifyOnlyDefaultBranch
150+
*/
151+
@Deprecated
146152
public void setNotifyOnlyDefaultBranch(Boolean notifyOnlyDefaultBranch) {
147153
setProperty(NOTIFY_ONLY_DEFAULT_BRANCH_PROP, notifyOnlyDefaultBranch);
148154
}
149155

156+
/**
157+
* @deprecated use {@link SlackService#withBranchesToBeNotified(BranchesToBeNotified)}
158+
* @param notifyOnlyDefaultBranch
159+
*/
160+
@Deprecated
150161
public SlackService withNotifyOnlyDefaultBranch(Boolean notifyOnlyDefaultBranch) {
151162
setNotifyOnlyDefaultBranch(notifyOnlyDefaultBranch);
152163
return (this);
153164
}
154165

166+
@JsonIgnore
167+
public BranchesToBeNotified getBranchesToBeNotified() {
168+
String branchesToBeNotified = getProperty(BRANCHES_TO_BE_NOTIFIED_PROP);
169+
170+
if (branchesToBeNotified == null || branchesToBeNotified.isEmpty()) {
171+
return null;
172+
}
173+
174+
return (BranchesToBeNotified.valueOf(branchesToBeNotified.toUpperCase()));
175+
}
176+
177+
public void setBranchesToBeNotified(BranchesToBeNotified branchesToBeNotified) {
178+
setProperty(BRANCHES_TO_BE_NOTIFIED_PROP, branchesToBeNotified.toString());
179+
}
180+
181+
public SlackService withBranchesToBeNotified(BranchesToBeNotified branchesToBeNotified) {
182+
setBranchesToBeNotified(branchesToBeNotified);
183+
return this;
184+
}
185+
155186
@JsonIgnore
156187
public String getPushChannel() {
157188
return ((String) getProperty(PUSH_CHANNEL_PROP));

src/test/resources/org/gitlab4j/api/slack-notifications.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"webhook": "https://hooks.slack.com/services/AAAA1BBB/ABCDEFGHI/aBCdef1Gerer65ere54gdffd",
1919
"username": "GitLab",
2020
"notify_only_broken_pipelines": false,
21-
"notify_only_default_branch": true,
21+
"branches_to_be_notified": "all",
2222
"push_channel": "pushes",
2323
"issue_channel": "",
2424
"confidential_issue_channel": "",

0 commit comments

Comments
 (0)