Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set API token in SlackNotificationConfig#getAsElement, fixes #86 #122

Merged
merged 1 commit into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ public SlackNotificationConfig(String token,
public Element getAsElement(){
Element el = new Element("slackNotification");
el.setAttribute(CHANNEL, this.getChannel());
if(StringUtil.isNotEmpty(this.getToken())) {
el.setAttribute(TOKEN, this.getToken());
}

if(StringUtil.isNotEmpty(this.getTeamName())) {
el.setAttribute(TEAM_NAME, this.getTeamName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public void testGetBuildStates() {
assertFalse(slacknotificationDisabled.getBuildStates().allEnabled());
}

@Test
public void testGetToken() {
assertTrue(slacknotificationAllEnabled.getToken().equals("hook.slack.com"));
}

@Test
public void testGetUrl() {
assertTrue(slacknotificationAllEnabled.getChannel().equals("http://localhost/test"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="true">
<slackNotification channel="http://localhost/test" enabled="true" format="nvpairs">
<slackNotification token="hook.slack.com" channel="http://localhost/test" enabled="true" format="nvpairs">
<states>
<state type="buildStarted" enabled="true" />
<state type="beforeBuildFinish" enabled="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="true">
<slackNotification channel="http://localhost/test" enabled="true" format="nvpairs">
<slackNotification token="hook.slack.com" channel="http://localhost/test" enabled="true" format="nvpairs">
<states>
<state type="buildStarted" enabled="false" />
<state type="beforeBuildFinish" enabled="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="true">
<slackNotification channel="http://localhost/test" enabled="true" format="nvpairs">
<slackNotification token="hook.slack.com" channel="http://localhost/test" enabled="true" format="nvpairs">
<states>
<state type="buildStarted" enabled="true" />
<state type="beforeBuildFinish" enabled="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="true">
<slackNotification channel="http://localhost/test" enabled="true" format="nvpairs">
<slackNotification token="hook.slack.com" channel="http://localhost/test" enabled="true" format="nvpairs">
<states>
<state type="buildStarted" enabled="true" />
<state type="beforeBuildFinish" enabled="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="true">
<slackNotification channel="http://localhost/test" enabled="true" format="nvpairs">
<slackNotification token="hook.slack.com" channel="http://localhost/test" enabled="true" format="nvpairs">
<states>
<state type="buildStarted" enabled="true" />
<state type="beforeBuildFinish" enabled="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="true">
<slackNotification channel="http://localhost/test" enabled="true" format="nvpairs">
<slackNotification token="hook.slack.com" channel="http://localhost/test" enabled="true" format="nvpairs">
<states>
<state type="buildStarted" enabled="true" />
<state type="beforeBuildFinish" enabled="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="true">
<slackNotification channel="http://localhost/test" enabled="true" format="nvpairs">
<slackNotification token="hook.slack.com" channel="http://localhost/test" enabled="true" format="nvpairs">
<states>
<state type="buildStarted" enabled="true" />
</states>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="true">
<slackNotification channel="http://localhost/test" enabled="false" format="nvpairs">
<slackNotification token="hook.slack.com" channel="http://localhost/test" enabled="false" format="nvpairs">
<states>
<state type="buildStarted" enabled="false" />
<state type="beforeBuildFinish" enabled="false" />
Expand Down
6 changes: 3 additions & 3 deletions tcslackbuildnotifier-core/src/test/resources/testdoc1.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<slackNotifications enabled="false">
<slackNotification enabled="true" channel="http://something" statemask="255">
<slackNotification enabled="true" token="hook.slack.com" channel="http://something" statemask="255">
<parameters>
<param name="foo" value="bar" />
</parameters>
</slackNotification>
<slackNotification enabled="true" channel="http://localhost.local.network/slacknotifications/test/test">
<slackNotification enabled="true" token="hook.slack.com" channel="http://localhost.local.network/slacknotifications/test/test">
<parameters>
<param name="fromTeamCity" value="%system.test.1%" />
</parameters>
</slackNotification>
<slackNotification enabled="false" channel="http://localhost.local.network/slacknotifications/test/teamcity" />
<slackNotification enabled="false" token="hook.slack.com" channel="http://localhost.local.network/slacknotifications/test/teamcity" />
</slackNotifications>
</settings>