-
Notifications
You must be signed in to change notification settings - Fork 651
/
Copy pathBuildServerList.cs
56 lines (48 loc) · 1.74 KB
/
BuildServerList.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
56
namespace GitVersion
{
using System;
using System.Collections.Generic;
public static class BuildServerList
{
static List<IBuildServer> BuildServers;
public static Func<Authentication, IEnumerable<IBuildServer>> Selector = arguments => DefaultSelector(arguments);
public static void ResetSelector()
{
Selector = DefaultSelector;
}
public static IEnumerable<IBuildServer> GetApplicableBuildServers(Authentication authentication)
{
return Selector(authentication);
}
static IEnumerable<IBuildServer> DefaultSelector(Authentication authentication)
{
if (BuildServers == null)
{
BuildServers = new List<IBuildServer>
{
new ContinuaCi(authentication),
new TeamCity(authentication),
new AppVeyor(authentication),
new MyGet(authentication)
};
}
var buildServices = new List<IBuildServer>();
foreach (var buildServer in BuildServers)
{
try
{
if (buildServer.CanApplyToCurrentContext())
{
Logger.WriteInfo(string.Format("Applicable build agent found: '{0}'.", buildServer.GetType().Name));
buildServices.Add(buildServer);
}
}
catch (Exception ex)
{
Logger.WriteWarning(string.Format("Failed to check build server '{0}': {1}", buildServer.GetType().Name, ex.Message));
}
}
return buildServices;
}
}
}