generated from reportportal/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
580bca0
commit 2dc23be
Showing
68 changed files
with
527 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
version=1.0.0 | ||
description=EPAM Report Portal. Slack plugin. | ||
pluginId = slack | ||
lombokVersion=1.18.36 | ||
junitVersion=5.11.0 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
java { | ||
sourceCompatibility = JavaVersion.VERSION_21 | ||
targetCompatibility = JavaVersion.VERSION_21 | ||
} | ||
|
||
def commonScriptsUrl = 'https://raw.githubusercontent.com/reportportal/gradle-scripts/' | ||
|
||
project.ext { | ||
publishRepo = "https://maven.pkg.github.com/reportportal/plugin-slack" | ||
releaseMode = project.hasProperty("releaseMode") | ||
pluginsDir = "$buildDir/jars" | ||
|
||
pluginsDir = "$buildDir/plugins" | ||
scriptsUrl = commonScriptsUrl + (releaseMode ? getProperty('scripts.version') : 'develop') | ||
excludeTests = [ | ||
'**/entity/**', | ||
'**/model/**', | ||
] | ||
limits = [ | ||
'instruction': 30, | ||
'branch' : 17, | ||
'line' : 30, | ||
'complexity' : 26, | ||
'method' : 29, | ||
'class' : 30 | ||
] | ||
} | ||
|
||
wrapper { | ||
gradleVersion = '5.4.1' | ||
gradleVersion = '8.10.2' | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
rootProject.name = 'plugin-slack-epam' | ||
include 'plugin-slack' | ||
rootProject.name = 'plugin-slack' | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,23 +27,23 @@ | |
import com.epam.ta.reportportal.entity.project.Project; | ||
import com.epam.ta.reportportal.entity.project.ProjectUtils; | ||
import com.epam.ta.reportportal.entity.project.email.SenderCase; | ||
import com.slack.api.Slack; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import org.apache.commons.lang3.BooleanUtils; | ||
import org.springframework.context.ApplicationListener; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Andrei Piankouski</a> | ||
*/ | ||
public class SlackLaunchFinishEventListener implements | ||
ApplicationListener<LaunchFinishedPluginEvent> { | ||
|
||
private final static String SLACK_NOTIFICATION_ATTRIBUTE = "notifications.slack.enabled"; | ||
public final static String SLACK_NOTIFICATION_ATTRIBUTE = "notifications.slack.enabled"; | ||
|
||
private final static String WEBHOOK_DETAILS = "webhookURL"; | ||
public final static String WEBHOOK_DETAILS = "webhookURL"; | ||
|
||
private final static String PLUGIN_NOTIFICATION_TYPE = "slack"; | ||
public final static String PLUGIN_NOTIFICATION_TYPE = "slack"; | ||
|
||
private final ProjectRepository projectRepository; | ||
|
||
|
@@ -52,15 +52,18 @@ public class SlackLaunchFinishEventListener implements | |
private final SenderCaseMatcher senderCaseMatcher; | ||
|
||
private final AttachmentResolver attachmentResolver; | ||
private final RestTemplate restTemplate; | ||
|
||
|
||
public SlackLaunchFinishEventListener( | ||
ProjectRepository projectRepository, LaunchRepository launchRepository, | ||
SenderCaseMatcher senderCaseMatcher, AttachmentResolver attachmentResolver) { | ||
SenderCaseMatcher senderCaseMatcher, AttachmentResolver attachmentResolver, | ||
RestTemplate restTemplate) { | ||
this.projectRepository = projectRepository; | ||
this.launchRepository = launchRepository; | ||
this.senderCaseMatcher = senderCaseMatcher; | ||
this.attachmentResolver = attachmentResolver; | ||
this.restTemplate = restTemplate; | ||
} | ||
|
||
@Override | ||
|
@@ -103,7 +106,7 @@ private void sendNotification(SenderCase senderCase, Launch launch, String launc | |
Optional<String> webhookUrl = getWebhookUrl(senderCase); | ||
Optional<String> attachment = resolveAttachment(launch, launchLink); | ||
if (webhookUrl.isPresent() && attachment.isPresent()) { | ||
sendSlackNotification(webhookUrl.get(), attachment.get()); | ||
restTemplate.postForLocation(webhookUrl.get(), attachment.get()); | ||
} | ||
} | ||
|
||
|
@@ -116,13 +119,6 @@ private Optional<String> resolveAttachment(Launch launch, String launchLink) { | |
return attachmentResolver.resolve(launch, launchLink); | ||
} | ||
|
||
private void sendSlackNotification(String webhookUrl, String attachment) { | ||
try (Slack slack = Slack.getInstance()) { | ||
slack.send(webhookUrl, attachment); | ||
} catch (Exception e) { | ||
throw new ReportPortalException("Failed to send Slack notification", e); | ||
} | ||
} | ||
|
||
private boolean isNotificationsEnabled(Project project) { | ||
Map<String, String> projectConfig = ProjectUtils.getConfigParameters( | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,4 +204,4 @@ | |
] | ||
} | ||
] | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.