From 8aa5513c17c80585f68d29945134e4f46d0301f4 Mon Sep 17 00:00:00 2001 From: "M. Tarik Yurt" Date: Tue, 18 Oct 2016 22:59:50 +0300 Subject: [PATCH 1/2] Implement bot-user support --- .../jenkins/plugins/slack/SlackNotifier.java | 45 +++++++-- .../plugins/slack/StandardSlackService.java | 96 +++++++++++-------- .../plugins/slack/workflow/SlackSendStep.java | 27 +++++- .../plugins/slack/SlackNotifier/config.jelly | 4 + .../plugins/slack/SlackNotifier/global.jelly | 3 + .../slack/workflow/SlackSendStep/config.jelly | 3 + .../plugins/slack/SlackNotifierStub.java | 6 +- .../plugins/slack/SlackNotifierTest.java | 2 +- .../slack/StandardSlackServiceStub.java | 4 +- .../slack/StandardSlackServiceTest.java | 29 ++++-- ...wordsCompatible_1_8_SlackNotifierTest.java | 4 + .../slack/workflow/SlackSendStepTest.java | 14 +-- .../jobs/Test_Slack_Plugin/config.xml | 1 + 13 files changed, 165 insertions(+), 73 deletions(-) diff --git a/src/main/java/jenkins/plugins/slack/SlackNotifier.java b/src/main/java/jenkins/plugins/slack/SlackNotifier.java index a9628b31..769ec802 100755 --- a/src/main/java/jenkins/plugins/slack/SlackNotifier.java +++ b/src/main/java/jenkins/plugins/slack/SlackNotifier.java @@ -33,6 +33,7 @@ public class SlackNotifier extends Notifier { private String teamDomain; private String authToken; + private boolean botUser; private String buildServerUrl; private String room; private String sendAs; @@ -66,8 +67,12 @@ public String getAuthToken() { return authToken; } + public boolean getBotUser() { + return botUser; + } + public String getBuildServerUrl() { - if(buildServerUrl == null || buildServerUrl == "") { + if(buildServerUrl == null || "".equals(buildServerUrl)) { JenkinsLocationConfiguration jenkinsConfig = new JenkinsLocationConfiguration(); return jenkinsConfig.getUrl(); } @@ -129,7 +134,7 @@ public String getCustomMessage() { } @DataBoundConstructor - public SlackNotifier(final String teamDomain, final String authToken, final String room, final String buildServerUrl, + public SlackNotifier(final String teamDomain, final String authToken, final boolean botUser, final String room, final String buildServerUrl, final String sendAs, final boolean startNotification, final boolean notifyAborted, final boolean notifyFailure, final boolean notifyNotBuilt, final boolean notifySuccess, final boolean notifyUnstable, final boolean notifyBackToNormal, final boolean notifyRepeatedFailure, final boolean includeTestSummary, CommitInfoChoice commitInfoChoice, @@ -137,6 +142,7 @@ public SlackNotifier(final String teamDomain, final String authToken, final Stri super(); this.teamDomain = teamDomain; this.authToken = authToken; + this.botUser = botUser; this.buildServerUrl = buildServerUrl; this.room = room; this.sendAs = sendAs; @@ -164,8 +170,10 @@ public SlackService newSlackService(AbstractBuild r, BuildListener listener) { teamDomain = getDescriptor().getTeamDomain(); } String authToken = this.authToken; + boolean botUser = this.botUser; if (StringUtils.isEmpty(authToken)) { authToken = getDescriptor().getToken(); + botUser = getDescriptor().getBotUser(); } String room = this.room; if (StringUtils.isEmpty(room)) { @@ -183,7 +191,7 @@ public SlackService newSlackService(AbstractBuild r, BuildListener listener) { authToken = env.expand(authToken); room = env.expand(room); - return new StandardSlackService(teamDomain, authToken, room); + return new StandardSlackService(teamDomain, authToken, botUser, room); } @Override @@ -210,6 +218,7 @@ public static class DescriptorImpl extends BuildStepDescriptor { private String teamDomain; private String token; + private boolean botUser; private String room; private String buildServerUrl; private String sendAs; @@ -228,12 +237,16 @@ public String getToken() { return token; } + public boolean getBotUser() { + return botUser; + } + public String getRoom() { return room; } public String getBuildServerUrl() { - if(buildServerUrl == null || buildServerUrl == "") { + if(buildServerUrl == null || "".equals(buildServerUrl)) { JenkinsLocationConfiguration jenkinsConfig = new JenkinsLocationConfiguration(); return jenkinsConfig.getUrl(); } @@ -254,6 +267,7 @@ public boolean isApplicable(Class aClass) { public SlackNotifier newInstance(StaplerRequest sr, JSONObject json) { String teamDomain = sr.getParameter("slackTeamDomain"); String token = sr.getParameter("slackToken"); + boolean botUser = "true".equals(sr.getParameter("slackBotUser")); String room = sr.getParameter("slackRoom"); boolean startNotification = "true".equals(sr.getParameter("slackStartNotification")); boolean notifySuccess = "true".equals(sr.getParameter("slackNotifySuccess")); @@ -267,7 +281,7 @@ public SlackNotifier newInstance(StaplerRequest sr, JSONObject json) { CommitInfoChoice commitInfoChoice = CommitInfoChoice.forDisplayName(sr.getParameter("slackCommitInfoChoice")); boolean includeCustomMessage = "on".equals(sr.getParameter("includeCustomMessage")); String customMessage = sr.getParameter("customMessage"); - return new SlackNotifier(teamDomain, token, room, buildServerUrl, sendAs, startNotification, notifyAborted, + return new SlackNotifier(teamDomain, token, botUser, room, buildServerUrl, sendAs, startNotification, notifyAborted, notifyFailure, notifyNotBuilt, notifySuccess, notifyUnstable, notifyBackToNormal, notifyRepeatedFailure, includeTestSummary, commitInfoChoice, includeCustomMessage, customMessage); } @@ -276,10 +290,11 @@ public SlackNotifier newInstance(StaplerRequest sr, JSONObject json) { public boolean configure(StaplerRequest sr, JSONObject formData) throws FormException { teamDomain = sr.getParameter("slackTeamDomain"); token = sr.getParameter("slackToken"); + botUser = "true".equals(sr.getParameter("slackBotUser")); room = sr.getParameter("slackRoom"); buildServerUrl = sr.getParameter("slackBuildServerUrl"); sendAs = sr.getParameter("slackSendAs"); - if(buildServerUrl == null || buildServerUrl == "") { + if(buildServerUrl == null || "".equals(buildServerUrl)) { JenkinsLocationConfiguration jenkinsConfig = new JenkinsLocationConfiguration(); buildServerUrl = jenkinsConfig.getUrl(); } @@ -290,8 +305,8 @@ public boolean configure(StaplerRequest sr, JSONObject formData) throws FormExce return super.configure(sr, formData); } - SlackService getSlackService(final String teamDomain, final String authToken, final String room) { - return new StandardSlackService(teamDomain, authToken, room); + SlackService getSlackService(final String teamDomain, final String authToken, final boolean botUser, final String room) { + return new StandardSlackService(teamDomain, authToken, botUser, room); } @Override @@ -301,6 +316,7 @@ public String getDisplayName() { public FormValidation doTestConnection(@QueryParameter("slackTeamDomain") final String teamDomain, @QueryParameter("slackToken") final String authToken, + @QueryParameter("slackBotUser") final boolean botUser, @QueryParameter("slackRoom") final String room, @QueryParameter("slackBuildServerUrl") final String buildServerUrl) throws FormException { try { @@ -309,8 +325,10 @@ public FormValidation doTestConnection(@QueryParameter("slackTeamDomain") final targetDomain = this.teamDomain; } String targetToken = authToken; + boolean targetBotUser = botUser; if (StringUtils.isEmpty(targetToken)) { targetToken = this.token; + targetBotUser = this.botUser; } String targetRoom = room; if (StringUtils.isEmpty(targetRoom)) { @@ -320,7 +338,7 @@ public FormValidation doTestConnection(@QueryParameter("slackTeamDomain") final if (StringUtils.isEmpty(targetBuildServerUrl)) { targetBuildServerUrl = this.buildServerUrl; } - SlackService testSlackService = getSlackService(targetDomain, targetToken, targetRoom); + SlackService testSlackService = getSlackService(targetDomain, targetToken, targetBotUser, targetRoom); String message = "Slack/Jenkins plugin: you're all set on " + targetBuildServerUrl; boolean success = testSlackService.publish(message, "good"); return success ? FormValidation.ok("Success") : FormValidation.error("Failure"); @@ -335,6 +353,7 @@ public static class SlackJobProperty extends hudson.model.JobProperty + + + + diff --git a/src/main/resources/jenkins/plugins/slack/SlackNotifier/global.jelly b/src/main/resources/jenkins/plugins/slack/SlackNotifier/global.jelly index f8885ed3..5ce08551 100755 --- a/src/main/resources/jenkins/plugins/slack/SlackNotifier/global.jelly +++ b/src/main/resources/jenkins/plugins/slack/SlackNotifier/global.jelly @@ -18,6 +18,9 @@ + + + diff --git a/src/main/resources/jenkins/plugins/slack/workflow/SlackSendStep/config.jelly b/src/main/resources/jenkins/plugins/slack/workflow/SlackSendStep/config.jelly index 541074b1..ec00db52 100644 --- a/src/main/resources/jenkins/plugins/slack/workflow/SlackSendStep/config.jelly +++ b/src/main/resources/jenkins/plugins/slack/workflow/SlackSendStep/config.jelly @@ -14,6 +14,9 @@ + + + diff --git a/src/test/java/jenkins/plugins/slack/SlackNotifierStub.java b/src/test/java/jenkins/plugins/slack/SlackNotifierStub.java index 6c27eb0f..3173f31a 100644 --- a/src/test/java/jenkins/plugins/slack/SlackNotifierStub.java +++ b/src/test/java/jenkins/plugins/slack/SlackNotifierStub.java @@ -2,12 +2,12 @@ public class SlackNotifierStub extends SlackNotifier { - public SlackNotifierStub(String teamDomain, String authToken, String room, String buildServerUrl, + public SlackNotifierStub(String teamDomain, String authToken, boolean botUser, String room, String buildServerUrl, String sendAs, boolean startNotification, boolean notifyAborted, boolean notifyFailure, boolean notifyNotBuilt, boolean notifySuccess, boolean notifyUnstable, boolean notifyBackToNormal, boolean notifyRepeatedFailure, boolean includeTestSummary, CommitInfoChoice commitInfoChoice, boolean includeCustomMessage, String customMessage) { - super(teamDomain, authToken, room, buildServerUrl, sendAs, startNotification, notifyAborted, notifyFailure, + super(teamDomain, authToken, botUser, room, buildServerUrl, sendAs, startNotification, notifyAborted, notifyFailure, notifyNotBuilt, notifySuccess, notifyUnstable, notifyBackToNormal, notifyRepeatedFailure, includeTestSummary, commitInfoChoice, includeCustomMessage, customMessage); } @@ -21,7 +21,7 @@ public synchronized void load() { } @Override - SlackService getSlackService(final String teamDomain, final String authToken, final String room) { + SlackService getSlackService(final String teamDomain, final String authToken, final boolean botUser, final String room) { return slackService; } diff --git a/src/test/java/jenkins/plugins/slack/SlackNotifierTest.java b/src/test/java/jenkins/plugins/slack/SlackNotifierTest.java index 068f4d61..f4a77dc8 100644 --- a/src/test/java/jenkins/plugins/slack/SlackNotifierTest.java +++ b/src/test/java/jenkins/plugins/slack/SlackNotifierTest.java @@ -47,7 +47,7 @@ public void testDoTestConnection() { } descriptor.setSlackService(slackServiceStub); try { - FormValidation result = descriptor.doTestConnection("teamDomain", "authToken", "room", "buildServerUrl"); + FormValidation result = descriptor.doTestConnection("teamDomain", "authToken", false, "room", "buildServerUrl"); assertEquals(result.kind, expectedResult); } catch (Descriptor.FormException e) { e.printStackTrace(); diff --git a/src/test/java/jenkins/plugins/slack/StandardSlackServiceStub.java b/src/test/java/jenkins/plugins/slack/StandardSlackServiceStub.java index 86b6294b..96046258 100644 --- a/src/test/java/jenkins/plugins/slack/StandardSlackServiceStub.java +++ b/src/test/java/jenkins/plugins/slack/StandardSlackServiceStub.java @@ -4,8 +4,8 @@ public class StandardSlackServiceStub extends StandardSlackService { private HttpClientStub httpClientStub; - public StandardSlackServiceStub(String teamDomain, String token, String roomId) { - super(teamDomain, token, roomId); + public StandardSlackServiceStub(String teamDomain, String token, boolean botUser, String roomId) { + super(teamDomain, token, botUser, roomId); } @Override diff --git a/src/test/java/jenkins/plugins/slack/StandardSlackServiceTest.java b/src/test/java/jenkins/plugins/slack/StandardSlackServiceTest.java index 9cd5c049..81ba8fc6 100755 --- a/src/test/java/jenkins/plugins/slack/StandardSlackServiceTest.java +++ b/src/test/java/jenkins/plugins/slack/StandardSlackServiceTest.java @@ -14,7 +14,7 @@ public class StandardSlackServiceTest { */ @Test public void publishWithBadHostShouldNotRethrowExceptions() { - StandardSlackService service = new StandardSlackService("foo", "token", "#general"); + StandardSlackService service = new StandardSlackService("foo", "token", false, "#general"); service.setHost("hostvaluethatwillcausepublishtofail"); service.publish("message"); } @@ -24,7 +24,7 @@ public void publishWithBadHostShouldNotRethrowExceptions() { */ @Test public void invalidTeamDomainShouldFail() { - StandardSlackService service = new StandardSlackService("my", "token", "#general"); + StandardSlackService service = new StandardSlackService("my", "token", false, "#general"); service.publish("message"); } @@ -33,13 +33,13 @@ public void invalidTeamDomainShouldFail() { */ @Test public void invalidTokenShouldFail() { - StandardSlackService service = new StandardSlackService("tinyspeck", "token", "#general"); + StandardSlackService service = new StandardSlackService("tinyspeck", "token", false, "#general"); service.publish("message"); } @Test public void publishToASingleRoomSendsASingleMessage() { - StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", "#room1"); + StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", false, "#room1"); HttpClientStub httpClientStub = new HttpClientStub(); service.setHttpClient(httpClientStub); service.publish("message"); @@ -48,7 +48,7 @@ public void publishToASingleRoomSendsASingleMessage() { @Test public void publishToMultipleRoomsSendsAMessageToEveryRoom() { - StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", "#room1,#room2,#room3"); + StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", false, "#room1,#room2,#room3"); HttpClientStub httpClientStub = new HttpClientStub(); service.setHttpClient(httpClientStub); service.publish("message"); @@ -57,7 +57,7 @@ public void publishToMultipleRoomsSendsAMessageToEveryRoom() { @Test public void successfulPublishToASingleRoomReturnsTrue() { - StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", "#room1"); + StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", false, "#room1"); HttpClientStub httpClientStub = new HttpClientStub(); httpClientStub.setHttpStatus(HttpStatus.SC_OK); service.setHttpClient(httpClientStub); @@ -66,7 +66,7 @@ public void successfulPublishToASingleRoomReturnsTrue() { @Test public void successfulPublishToMultipleRoomsReturnsTrue() { - StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", "#room1,#room2,#room3"); + StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", false, "#room1,#room2,#room3"); HttpClientStub httpClientStub = new HttpClientStub(); httpClientStub.setHttpStatus(HttpStatus.SC_OK); service.setHttpClient(httpClientStub); @@ -75,7 +75,7 @@ public void successfulPublishToMultipleRoomsReturnsTrue() { @Test public void failedPublishToASingleRoomReturnsFalse() { - StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", "#room1"); + StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", false, "#room1"); HttpClientStub httpClientStub = new HttpClientStub(); httpClientStub.setHttpStatus(HttpStatus.SC_NOT_FOUND); service.setHttpClient(httpClientStub); @@ -84,7 +84,7 @@ public void failedPublishToASingleRoomReturnsFalse() { @Test public void singleFailedPublishToMultipleRoomsReturnsFalse() { - StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", "#room1,#room2,#room3"); + StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", false, "#room1,#room2,#room3"); HttpClientStub httpClientStub = new HttpClientStub(); httpClientStub.setFailAlternateResponses(true); httpClientStub.setHttpStatus(HttpStatus.SC_OK); @@ -94,7 +94,16 @@ public void singleFailedPublishToMultipleRoomsReturnsFalse() { @Test public void publishToEmptyRoomReturnsTrue() { - StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", ""); + StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", false, ""); + HttpClientStub httpClientStub = new HttpClientStub(); + httpClientStub.setHttpStatus(HttpStatus.SC_OK); + service.setHttpClient(httpClientStub); + assertTrue(service.publish("message")); + } + + @Test + public void sendAsBotUserReturnsTrue() { + StandardSlackServiceStub service = new StandardSlackServiceStub("domain", "token", true, "#room1"); HttpClientStub httpClientStub = new HttpClientStub(); httpClientStub.setHttpStatus(HttpStatus.SC_OK); service.setHttpClient(httpClientStub); diff --git a/src/test/java/jenkins/plugins/slack/config/BackwordsCompatible_1_8_SlackNotifierTest.java b/src/test/java/jenkins/plugins/slack/config/BackwordsCompatible_1_8_SlackNotifierTest.java index d2fc9865..5939b444 100644 --- a/src/test/java/jenkins/plugins/slack/config/BackwordsCompatible_1_8_SlackNotifierTest.java +++ b/src/test/java/jenkins/plugins/slack/config/BackwordsCompatible_1_8_SlackNotifierTest.java @@ -42,6 +42,7 @@ public void testBasicMigration() { assertEquals("jenkins-slack-plugin", notifier.getTeamDomain()); assertEquals("auth-token-for-test", notifier.getAuthToken()); + assertEquals(false, notifier.getBotUser()); assertEquals("http://localhost:8080/", notifier.getBuildServerUrl()); assertEquals("#slack-plugin-testing", notifier.getRoom()); @@ -69,6 +70,7 @@ public void testGlobalSettingsOverriden() { assertEquals("jenkins-slack-plugin", notifier.getTeamDomain()); assertEquals("auth-token-for-test", notifier.getAuthToken()); + assertEquals(false, notifier.getBotUser()); assertEquals("http://localhost:8080/", notifier.getBuildServerUrl()); assertEquals("#slack-plugin-testing", notifier.getRoom()); @@ -96,6 +98,7 @@ public void testGlobalSettingsNotOverridden() throws IOException { assertEquals("", notifier.getTeamDomain()); assertEquals("", notifier.getAuthToken()); + assertEquals(false, notifier.getBotUser()); assertEquals(j.getURL().toString(), notifier.getBuildServerUrl()); assertEquals("", notifier.getRoom()); @@ -151,6 +154,7 @@ public void testMigrationOfSomeJobs() throws IOException { assertEquals("", notifier.getTeamDomain()); assertEquals("", notifier.getAuthToken()); + assertEquals(false, notifier.getBotUser()); assertEquals(j.getURL().toString(), notifier.getBuildServerUrl()); assertEquals("", notifier.getRoom()); diff --git a/src/test/java/jenkins/plugins/slack/workflow/SlackSendStepTest.java b/src/test/java/jenkins/plugins/slack/workflow/SlackSendStepTest.java index 3153ca96..31d28724 100644 --- a/src/test/java/jenkins/plugins/slack/workflow/SlackSendStepTest.java +++ b/src/test/java/jenkins/plugins/slack/workflow/SlackSendStepTest.java @@ -55,6 +55,7 @@ public void testStepOverrides() throws Exception { SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution()); SlackSendStep slackSendStep = new SlackSendStep("message"); slackSendStep.setToken("token"); + slackSendStep.setBotUser(false); slackSendStep.setTeamDomain("teamDomain"); slackSendStep.setChannel("channel"); slackSendStep.setColor("good"); @@ -65,16 +66,16 @@ public void testStepOverrides() throws Exception { stepExecution.listener = taskListenerMock; when(slackDescMock.getToken()).thenReturn("differentToken"); - + when(slackDescMock.getBotUser()).thenReturn(true); when(taskListenerMock.getLogger()).thenReturn(printStreamMock); doNothing().when(printStreamMock).println(); - when(stepExecution.getSlackService(anyString(), anyString(), anyString())).thenReturn(slackServiceMock); + when(stepExecution.getSlackService(anyString(), anyString(), anyBoolean(), anyString())).thenReturn(slackServiceMock); when(slackServiceMock.publish(anyString(), anyString())).thenReturn(true); stepExecution.run(); - verify(stepExecution, times(1)).getSlackService("teamDomain", "token", "channel"); + verify(stepExecution, times(1)).getSlackService("teamDomain", "token", false, "channel"); verify(slackServiceMock, times(1)).publish("message", "good"); assertFalse(stepExecution.step.isFailOnError()); } @@ -91,15 +92,16 @@ public void testValuesForGlobalConfig() throws Exception { when(slackDescMock.getTeamDomain()).thenReturn("globalTeamDomain"); when(slackDescMock.getToken()).thenReturn("globalToken"); + when(slackDescMock.getBotUser()).thenReturn(false); when(slackDescMock.getRoom()).thenReturn("globalChannel"); when(taskListenerMock.getLogger()).thenReturn(printStreamMock); doNothing().when(printStreamMock).println(); - when(stepExecution.getSlackService(anyString(), anyString(), anyString())).thenReturn(slackServiceMock); + when(stepExecution.getSlackService(anyString(), anyString(), anyBoolean(), anyString())).thenReturn(slackServiceMock); stepExecution.run(); - verify(stepExecution, times(1)).getSlackService("globalTeamDomain", "globalToken", "globalChannel"); + verify(stepExecution, times(1)).getSlackService("globalTeamDomain", "globalToken", false, "globalChannel"); verify(slackServiceMock, times(1)).publish("message", ""); assertNull(stepExecution.step.getTeamDomain()); assertNull(stepExecution.step.getToken()); @@ -122,7 +124,7 @@ public void testNonNullEmptyColor() throws Exception { when(taskListenerMock.getLogger()).thenReturn(printStreamMock); doNothing().when(printStreamMock).println(); - when(stepExecution.getSlackService(anyString(), anyString(), anyString())).thenReturn(slackServiceMock); + when(stepExecution.getSlackService(anyString(), anyString(), anyBoolean(), anyString())).thenReturn(slackServiceMock); stepExecution.run(); verify(slackServiceMock, times(1)).publish("message", ""); diff --git a/src/test/resources/jenkins/plugins/slack/config/BackwordsCompatible_1_8_SlackNotifierTest/testGlobalSettingsNotOverridden/jobs/Test_Slack_Plugin/config.xml b/src/test/resources/jenkins/plugins/slack/config/BackwordsCompatible_1_8_SlackNotifierTest/testGlobalSettingsNotOverridden/jobs/Test_Slack_Plugin/config.xml index 73edbacb..7b976eaf 100644 --- a/src/test/resources/jenkins/plugins/slack/config/BackwordsCompatible_1_8_SlackNotifierTest/testGlobalSettingsNotOverridden/jobs/Test_Slack_Plugin/config.xml +++ b/src/test/resources/jenkins/plugins/slack/config/BackwordsCompatible_1_8_SlackNotifierTest/testGlobalSettingsNotOverridden/jobs/Test_Slack_Plugin/config.xml @@ -38,6 +38,7 @@ + From 62a695af0b1ab9198c4940e890cc868937e3cfa5 Mon Sep 17 00:00:00 2001 From: "M. Tarik Yurt" Date: Thu, 1 Dec 2016 23:45:30 +0300 Subject: [PATCH 2/2] Add README section for bot user support & change help information for bot user option --- README.md | 7 +++++++ .../jenkins/plugins/slack/SlackNotifier/config.jelly | 2 +- .../jenkins/plugins/slack/SlackNotifier/global.jelly | 2 +- src/main/webapp/help-globalConfig-botUser.html | 4 ++++ src/main/webapp/help-projectConfig-botUser.html | 4 ++++ 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/main/webapp/help-globalConfig-botUser.html create mode 100644 src/main/webapp/help-projectConfig-botUser.html diff --git a/README.md b/README.md index 9937aec5..ff54d9dc 100755 --- a/README.md +++ b/README.md @@ -21,6 +21,13 @@ Create a new ***Secret text*** credential: Select that credential as the value for the ***Integration Token Credential ID*** field: ![image](https://cloud.githubusercontent.com/assets/983526/17971458/ec296bf6-6aa8-11e6-8d19-06d9f1c9d611.png) + +#### Bot user option +This plugin supports sending notifications via bot users. You can enable bot user support from both +global and project configurations. If the notification will be sent to a user via direct message, +default integration sends it via @slackbot, you can use this option if you want to send messages via a bot user. +You need to provide credentials of the bot user for integration token credentials to use this feature. + #### Jenkins Pipeline Support Includes [Jenkins Pipeline](https://github.com/jenkinsci/workflow-plugin) support as of version 2.0: diff --git a/src/main/resources/jenkins/plugins/slack/SlackNotifier/config.jelly b/src/main/resources/jenkins/plugins/slack/SlackNotifier/config.jelly index 0553dafb..61974cd3 100755 --- a/src/main/resources/jenkins/plugins/slack/SlackNotifier/config.jelly +++ b/src/main/resources/jenkins/plugins/slack/SlackNotifier/config.jelly @@ -63,7 +63,7 @@ - + diff --git a/src/main/resources/jenkins/plugins/slack/SlackNotifier/global.jelly b/src/main/resources/jenkins/plugins/slack/SlackNotifier/global.jelly index db06684a..d7725a30 100755 --- a/src/main/resources/jenkins/plugins/slack/SlackNotifier/global.jelly +++ b/src/main/resources/jenkins/plugins/slack/SlackNotifier/global.jelly @@ -21,7 +21,7 @@ - + diff --git a/src/main/webapp/help-globalConfig-botUser.html b/src/main/webapp/help-globalConfig-botUser.html new file mode 100644 index 00000000..5fceabb6 --- /dev/null +++ b/src/main/webapp/help-globalConfig-botUser.html @@ -0,0 +1,4 @@ +
+

Bot user option indicates the token belongs to a bot user in Slack.

+

If the notification will be sent to a user via direct message, the default integration sends it via @slackbot, use this option if you want to send messages via a bot user.

+
\ No newline at end of file diff --git a/src/main/webapp/help-projectConfig-botUser.html b/src/main/webapp/help-projectConfig-botUser.html new file mode 100644 index 00000000..5fceabb6 --- /dev/null +++ b/src/main/webapp/help-projectConfig-botUser.html @@ -0,0 +1,4 @@ +
+

Bot user option indicates the token belongs to a bot user in Slack.

+

If the notification will be sent to a user via direct message, the default integration sends it via @slackbot, use this option if you want to send messages via a bot user.

+
\ No newline at end of file