-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnotifications.cake
53 lines (40 loc) · 1.73 KB
/
notifications.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#l "notifications-msteams.cake"
//#l "notifications-slack.cake"
//-------------------------------------------------------------
public enum NotificationType
{
Info,
Error
}
//-------------------------------------------------------------
public interface INotifier
{
Task NotifyAsync(string project, string message, TargetType targetType = TargetType.Unknown, NotificationType notificationType = NotificationType.Info);
}
//-------------------------------------------------------------
public class NotificationsIntegration : IntegrationBase
{
private readonly List<INotifier> _notifiers = new List<INotifier>();
public NotificationsIntegration(BuildContext buildContext)
: base(buildContext)
{
_notifiers.Add(new MsTeamsNotifier(buildContext));
}
public async Task NotifyDefaultAsync(string project, string message, TargetType targetType = TargetType.Unknown)
{
await NotifyAsync(project, message, targetType, NotificationType.Info);
}
//-------------------------------------------------------------
public async Task NotifyErrorAsync(string project, string message, TargetType targetType = TargetType.Unknown)
{
await NotifyAsync(project, string.Format("ERROR: {0}", message), targetType, NotificationType.Error);
}
//-------------------------------------------------------------
public async Task NotifyAsync(string project, string message, TargetType targetType = TargetType.Unknown, NotificationType notificationType = NotificationType.Info)
{
foreach (var notifier in _notifiers)
{
await notifier.NotifyAsync(project, message, targetType, notificationType);
}
}
}