public async Task ConnectAsync(VssConnection jobConnection) { ArgUtil.NotNull(jobConnection, nameof(jobConnection)); _connection = jobConnection; int attemptCount = 5; while (!_connection.HasAuthenticated && attemptCount-- > 0) { try { await _connection.ConnectAsync(); break; } catch (Exception ex) when(attemptCount > 0) { Trace.Info($"Catch exception during connect. {attemptCount} attemp left."); Trace.Error(ex); } await Task.Delay(100); } _buildHttpClient = _connection.GetClient <Build2.BuildHttpClient>(); }
public BuildClient(Uri baseUrl, VssCredentials credentials, int retryCount, int retryInterval) { var vssConnection = new VssConnection(baseUrl, credentials); this.client = vssConnection.GetClient <BuildHttpClient>(); this.retryer = Retryer.CreateRetryer(retryCount, TimeSpan.FromSeconds(retryInterval)); }
public BuildServer(VssConnection connection, Guid projectId) { ArgUtil.NotNull(connection, nameof(connection)); ArgUtil.NotEmpty(projectId, nameof(projectId)); _projectId = projectId; _buildHttpClient = connection.GetClient <Build2.BuildHttpClient>(); }
internal TfsBuild2Helper(Uri tpcUrl) { this.connection = new VssConnection(tpcUrl, new VssClientCredentials(true)); this.client = connection.GetClient <TFSWebApi.BuildHttpClient>(); // Connect to tfs server var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcUrl); tpc.EnsureAuthenticated(); // Connect to version control service this.versionControl = tpc.GetService <VSClient.VersionControlServer>(); }
public BuildServer( Uri projectCollection, VssCredentials credentials, Guid projectId) { ArgUtil.NotNull(projectCollection, nameof(projectCollection)); ArgUtil.NotNull(credentials, nameof(credentials)); ArgUtil.NotEmpty(projectId, nameof(projectId)); _projectCollectionUrl = projectCollection; _credential = credentials; _projectId = projectId; BuildHttpClient = new Build2.BuildHttpClient(projectCollection, credentials, new VssHttpRetryMessageHandler(3)); }
public ResolverVNextBuildResult(ISettings <ResolverValidSettings> settings) { ResolverType = "Resolver_BuildResultJSON"; Logger.Instance().Log(TraceLevel.Info, "Initializing resolver {0} ...", ResolverType); if (settings == null) { throw new InvalidProviderConfigurationException(string.Format("Invalid connection settings were supplied")); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl))) { throw new InvalidProviderConfigurationException(string.Format("No team project collection url was supplied")); } if (string.IsNullOrEmpty(settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList))) { throw new InvalidProviderConfigurationException(string.Format("No dependency definition file name list was supplied")); } _dependencyDefinitionFileNameList = settings.GetSetting(ResolverValidSettings.DependencyDefinitionFileNameList).Split(new[] { ';' }).ToList(); ComponentTargetsName = _dependencyDefinitionFileNameList.First(); ResolverSettings = settings; var tpcUrl = new Uri(settings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl)); _connection = new VssConnection(tpcUrl, new VssClientCredentials(true)); _client = _connection.GetClient <TFSWebApi.BuildHttpClient>(); // Connect to tfs server var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcUrl); tpc.EnsureAuthenticated(); // Connect to version control service & build server _versionControlServer = tpc.GetService <VersionControlServer>(); if (_versionControlServer == null) { Logger.Instance().Log(TraceLevel.Error, "{0}: Could not get VersionControlServer service for {1}", ResolverType, ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl)); throw new InvalidProviderConfigurationException(string.Format("Could not get VersionControlServer service for {0} in {1}", ResolverSettings.GetSetting(ResolverValidSettings.TeamProjectCollectionUrl), ResolverType)); } Logger.Instance().Log(TraceLevel.Info, "Resolver {0} successfully initialized", ResolverType); }
public BuildHttpClientWrapper(ILoggerService loggerService, WebApi.BuildHttpClient inner) { _loggerService = loggerService ?? throw new ArgumentNullException(nameof(loggerService)); _inner = inner ?? throw new ArgumentNullException(nameof(inner)); }