forked from pauldotknopf/dotnet-buildary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTravis.cs
55 lines (47 loc) · 1.55 KB
/
Travis.cs
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
54
55
using System;
namespace Build.Buildary
{
public class Travis
{
public enum EventTypeEnum
{
Push,
PullRequest,
Api,
Cron,
Unknown
}
public static bool IsTravis => Environment.GetEnvironmentVariable("TRAVIS") == "true";
public static EventTypeEnum EventType
{
get
{
switch(Environment.GetEnvironmentVariable("TRAVIS_EVENT_TYPE"))
{
case "push":
return EventTypeEnum.Push;
case "pull_request":
return EventTypeEnum.PullRequest;
case "api":
return EventTypeEnum.Api;
case "cron":
return EventTypeEnum.Cron;
default:
return EventTypeEnum.Unknown;
}
}
}
public static bool IsTagBuild => !string.IsNullOrEmpty(Tag);
public static string Tag => Environment.GetEnvironmentVariable("TRAVIS_TAG");
public static string Branch => Environment.GetEnvironmentVariable("TRAVIS_BRANCH");
public static string Commit => Environment.GetEnvironmentVariable("TRAVIS_COMMIT");
public static bool IsPullRequest
{
get
{
bool.TryParse(Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST"), out var result);
return result;
}
}
}
}