Skip to content

Commit 07af2dc

Browse files
committed
Release version 2.4.0
2 parents db3cf25 + 8523923 commit 07af2dc

11 files changed

Lines changed: 142 additions & 61 deletions

File tree

CHANGELOG.markdown

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#2.4.0
2+
3+
* Added issues as attachment
4+
* Support for new Slack url format (droped splitting url & token that wasn't needed)
5+
6+
#2.3.0
7+
8+
* skipped - internal / test / scrapped version, not needed
9+
10+
11+
#2.2.0
12+
13+
* added support for notifying build start and failute. disabled by default can be enabled in xml settings - see README
14+
15+

README.markdown

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ Gradle is used to build. Wrapper is included in the project so you dont need to
1010

1111
./gradlew buildZip
1212

13-
this will generate a zip file with the right meta data in the right folder structure at : `build/distributions/TCSlackNotifierPlugin-<version>.zip`
13+
this will generate a zip file with the right meta data in the right folder structure at : `build/distributions/TCSlackNotifierPlugin-<version>.zip` you can also download a build from GitHubs versions section.
1414

1515
#Install Plugin
1616

1717
Copy the zip file into TeamCity plugin directory inside the data directory, usually `.BuildServer`
1818

1919
```
20-
scp build/distributions/TCSlackNotifierPlugin-<version>.zip buildserver:.BuildServer/plugins/slackNotifier.zip
20+
scp build/distributions/TCSlackNotifierPlugin-<version>.zip buildserver:.BuildServer/plugins/
2121
```
2222

2323
Then restart TeamCity.
2424

2525
#Configuration
2626

2727
###In slack
28-
Add a new webhook integration. Make a note of the Token.
28+
Add a new webhook integration. Make a note of the URL.
2929

3030
###In TeamCity
3131

@@ -35,9 +35,8 @@ Edit the main config file, usually `.BuildServer/config/main-config.xml` and add
3535
<server rootURL="http://localhost:8111">
3636
...
3737
<slackNotifier postSuccessful="true" postFailed="false" postStarted="false" >
38-
<slackWebToken>testToken2</slackWebToken>
3938
<slackDefaultChannel>#general</slackDefaultChannel>
40-
<slackPostUrl>https://tapadoo.slack.com/services/hooks/incoming-webhook?token=</slackPostUrl>
39+
<slackPostUrl>https://hooks.slack.com/services/YYYYYY/XXXXXXX/ZZZZZZZZZZZZ</slackPostUrl>
4140
<slackLogoUrl>http://build.tapadoo.com/img/icons/TeamCity32.png</slackLogoUrl>
4241
</slackNotifier>
4342
...
@@ -46,31 +45,33 @@ Edit the main config file, usually `.BuildServer/config/main-config.xml` and add
4645

4746
You can set the attributes on slackNotifier element (postSuccessful,postFailed,postStarted) to decide that notifications you would like posted.
4847

49-
Replace the web token with the token from slack. Change the postUrl also to point to the right slack team. The url can be found in the webhook integraton page, just remove the token from the end. Change the logo url whatever you want.
48+
Set the **slackPostUrl** to point to the url provided on the Slack integration page for the incoming webhook you created. Change the logo url whatever you want or leave it out.
5049

5150
This by default will post all builds to slack. you can tweak these on a project level though
5251

5352
####Project Config (Optional)
5453

55-
To change channel or disable per project:
54+
To change channel, change the slack logo used for that project or disable per project:
5655

5756
Edit the plugin specific xml config, `plugin-settings.xml` probably somewhere inside `.BuildServer/config/projects/PROJECTNAME`
57+
5858
```
5959
<settings>
6060
<slackSettings enabled="true">
6161
<channel>#blah</channel>
62+
<logoUrl>http://host/somelogo.png</logoUrl>
6263
</slackSettings>
6364
</settings>
6465
```
6566

6667
#Note on TeamCity version support
6768

68-
I'm still using **TeamCity 7.1** , but a few tests on the free version of TeamCity 8 went fine, and it seems to work there also.
69+
I'm still using **TeamCity 7.1** , but a few tests on the free version of TeamCity 8 went fine, and it seems to work there also. Have yet to test on TeamCity 9 but whats the chance it doesn't work?
6970

7071
###Issues
7172

7273
* all xml config - needs web ui extensions for updating settings from GUI. Considering it.
73-
* channel can be changed per-project either by environmental variable (SLACK_CHANNEL) or by changing the project specific xml in the data directory. This could also use web ui extension UI for editing.
74+
* channel can be changed per-project either by environmental variable (SLACK_CHANNEL (env var may be broken)) or by changing the project specific xml in the data directory. This could also use web ui extension UI for editing.
7475
* All or nothing notifications. By default, all builds are posted. It can be disabled per project, but not currently by build config.
7576

7677

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ repositories {
66
apply plugin: 'java'
77

88

9-
sourceCompatibility = 1.5
10-
version = '2.2.0'
9+
sourceCompatibility = 1.6
10+
version = '2.4.0'
1111

1212
configurations {
1313
deploy

src/main/java/com/tapadoo/slacknotifier/SlackConfigProcessor.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111
public class SlackConfigProcessor implements MainConfigProcessor {
1212

13-
public static final String PREF_KEY_SLACK_WEB_TOKEN = "slackWebToken";
1413
public static final String PREF_KEY_SLACK_DEF_CHANNEL = "slackDefaultChannel";
1514
public static final String PREF_KEY_SLACK_POSTURL = "slackPostUrl";
1615
public static final String PREF_KEY_SLACK_LOGOURL = "slackLogoUrl";
@@ -21,8 +20,6 @@ public class SlackConfigProcessor implements MainConfigProcessor {
2120
private static final java.lang.String ATTR_NAME_POST_STARTED = "postStarted" ;
2221
private static final java.lang.String ATTR_NAME_POST_FAILED = "postFailed" ;
2322

24-
25-
private String token = "invalidToken";
2623
private String defaultChannel = "#general";
2724
private String postUrl;
2825
private String logoUrl;
@@ -56,14 +53,6 @@ public boolean postStarted()
5653
return postStarted ;
5754
}
5855

59-
public String getToken() {
60-
return token;
61-
}
62-
63-
public void setToken(String token) {
64-
this.token = token;
65-
}
66-
6756
public String getDefaultChannel() {
6857
return defaultChannel;
6958
}
@@ -93,12 +82,10 @@ public void readFrom(org.jdom.Element element) {
9382

9483
if( mainConfigElement == null )
9584
{
96-
token = "" ;
97-
postUrl = "http://localhost/?token=" ;
85+
postUrl = "http://localhost/" ;
9886
return ;
9987
}
10088

101-
token = mainConfigElement.getChildText(PREF_KEY_SLACK_WEB_TOKEN);
10289
defaultChannel = mainConfigElement.getChildText(PREF_KEY_SLACK_DEF_CHANNEL);
10390
postUrl = mainConfigElement.getChildText(PREF_KEY_SLACK_POSTURL);
10491
logoUrl = mainConfigElement.getChildText(PREF_KEY_SLACK_LOGOURL);
@@ -145,15 +132,12 @@ public void readFrom(org.jdom.Element element) {
145132
public void writeTo(org.jdom.Element element) {
146133

147134
Element mainConfigElement = new Element(PREF_CHILD_ELEMENT);
148-
Element webTokenElement = new Element(PREF_KEY_SLACK_WEB_TOKEN);
149135
Element defChannelElement = new Element(PREF_KEY_SLACK_DEF_CHANNEL);
150136
Element postUrlElement = new Element(PREF_KEY_SLACK_POSTURL);
151137
Element logoUrlElement = new Element(PREF_KEY_SLACK_LOGOURL);
152138

153-
webTokenElement.setText(token);
154139
defChannelElement.setText(defaultChannel);
155140

156-
mainConfigElement.addContent(webTokenElement);
157141
mainConfigElement.addContent(defChannelElement);
158142
mainConfigElement.addContent(postUrlElement);
159143
mainConfigElement.addContent(logoUrlElement);

src/main/java/com/tapadoo/slacknotifier/SlackProjectSettings.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
*/
1111
public class SlackProjectSettings implements ProjectSettings {
1212

13+
public static final String ELEMENT_LOGO_URL = "logoUrl";
14+
public static final String ATTR_ENABLED = "enabled";
15+
public static final String ELEMENT_CHANNEL = "channel";
1316
private String projectId;
1417
private String channel;
18+
private String logoUrl;
1519
private boolean enabled = true ;
1620

1721
public SlackProjectSettings(String projectId) {
@@ -31,6 +35,14 @@ public void setChannel(String channel) {
3135
this.channel = channel;
3236
}
3337

38+
public String getLogoUrl() {
39+
return logoUrl;
40+
}
41+
42+
public void setLogoUrl(String logoUrl) {
43+
this.logoUrl = logoUrl;
44+
}
45+
3446
public boolean isEnabled()
3547
{
3648
return this.enabled;
@@ -41,8 +53,9 @@ public void dispose() {
4153
}
4254

4355
public void readFrom(Element element) {
44-
Element channelElement = element.getChild("channel");
45-
Attribute enabledAttr = element.getAttribute("enabled");
56+
Element channelElement = element.getChild(ELEMENT_CHANNEL);
57+
Element logoElement = element.getChild(ELEMENT_LOGO_URL);
58+
Attribute enabledAttr = element.getAttribute(ATTR_ENABLED);
4659

4760
if( enabledAttr != null )
4861
{
@@ -60,17 +73,26 @@ public void readFrom(Element element) {
6073
if( channelElement != null ) {
6174
this.channel = channelElement.getText();
6275
}
76+
77+
if( logoElement != null )
78+
{
79+
this.logoUrl = logoElement.getText();
80+
}
6381
}
6482

6583
public void writeTo(Element element) {
6684

67-
Element channelElement = new Element("channel");
85+
Element channelElement = new Element(ELEMENT_CHANNEL);
6886
channelElement.setText(this.channel);
6987

70-
Attribute enabledAttr = new Attribute("enabled",Boolean.toString(enabled)) ;
88+
Element logoUrlElement = new Element(ELEMENT_LOGO_URL);
89+
logoUrlElement.setText(this.logoUrl);
90+
91+
Attribute enabledAttr = new Attribute(ATTR_ENABLED,Boolean.toString(enabled)) ;
7192
element.setAttribute( enabledAttr );
7293

7394
element.addContent(channelElement);
95+
element.addContent(logoUrlElement);
7496
}
7597

7698
}

0 commit comments

Comments
 (0)