Skip to content

Commit 3660a76

Browse files
committed
Update plugin config to allow specification of complete weboook url
(fixes #3)
1 parent ae327e0 commit 3660a76

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## Gitblit Slack plugin
22

3+
## 1.4.0-SNAPSHOT
4+
5+
- Update to Gitblit 1.7.0
6+
- Add `slack.url` config setting
7+
- Remove `slack.team`
8+
- Remove `slack.token`
9+
310
### 1.3.0
411

512
- Post events using user identity & gravatar, may be disabled

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ Alternatively, you can download the zip from [here](http://plugins.gitblit.com)
1818

1919
### Setup
2020

21-
At a bare minimum you'll need two settings configured in `gitblit.properties`.
21+
At a bare minimum you'll need one setting configured in `gitblit.properties`.
22+
23+
slack.url = https://hooks.slack.com/services/yada/yadayada
2224

23-
slack.team = yourTeam
24-
slack.token = yourToken
2525

2626
If you have the `powertools` plugin installed, you may configure this over SSH:
2727

28-
ssh host gb config slack.team yourTeam
29-
ssh host gb config slack.token yourToken
28+
ssh host gb config slack.url https://hooks.slack.com/services/yada/yadayada
29+
3030

3131
There a handful of additional optional settings:
3232

src/main/java/com/gitblit/plugin/slack/Plugin.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424

2525
public class Plugin extends GitblitPlugin {
2626

27-
public static final String SETTING_TEAM = "slack.team";
28-
29-
public static final String SETTING_HOOK = "slack.hook";
30-
31-
public static final String SETTING_TOKEN = "slack.token";
27+
public static final String SETTING_URL = "slack.url";
3228

3329
public static final String SETTING_POST_AS_USER = "slack.postAsUser";
3430

src/main/java/com/gitblit/plugin/slack/Slacker.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,11 @@ public boolean shallPost(RepositoryModel repository) {
104104
}
105105

106106
public String getURL() throws IOException {
107-
String team = runtimeManager.getSettings().getString(Plugin.SETTING_TEAM, null);
108-
if (StringUtils.isEmpty(team)) {
109-
throw new IOException(String.format("Could not send message to Slack because '%s' is not defined!", Plugin.SETTING_TEAM));
107+
String url = runtimeManager.getSettings().getString(Plugin.SETTING_URL, null);
108+
if (StringUtils.isEmpty(url)) {
109+
throw new IOException(String.format("Could not send message to Slack because '%s' is not defined!", Plugin.SETTING_URL));
110110
}
111-
112-
String token = runtimeManager.getSettings().getString(Plugin.SETTING_TOKEN, null);
113-
if (StringUtils.isEmpty(token)) {
114-
throw new IOException(String.format("Could not send message to Slack because '%s' is not defined!", Plugin.SETTING_TOKEN));
115-
}
116-
117-
String hook = runtimeManager.getSettings().getString(Plugin.SETTING_HOOK, "incoming-webhook");
118-
if (StringUtils.isEmpty(hook)) {
119-
hook = "incoming-webhook";
120-
}
121-
122-
return String.format("https://%s.slack.com/services/hooks/%s?token=%s", team.toLowerCase(), hook, token);
111+
return url;
123112
}
124113

125114
/**

0 commit comments

Comments
 (0)