public TeamCityWebClient(ITeamCityConnectionInfo connectionInfo)
        {
            this.BaseAddress = connectionInfo.GetApiUrl();

            if (!string.IsNullOrEmpty(connectionInfo.UserName))
            {
                // Using a CredentialCache because API URLs with TeamCity variables in them will issue redirects
                // to the actual URLs, and unlike the NetworkCredential class, CredentialCache will ensure that the
                // credentials will be sent to the redirected URL as well
                var credentials = new CredentialCache();
                credentials.Add(new Uri(connectionInfo.GetApiUrl()), "Basic", new NetworkCredential(connectionInfo.UserName, connectionInfo.Password));
                this.Credentials = credentials;
            }
        }
        public TeamCityArtifactImporter(ITeamCityConnectionInfo connectionInfo, ILogSink logger, IGenericBuildMasterContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (context.ApplicationId == null)
            {
                throw new InvalidOperationException("context requires a valid application ID");
            }

            this.ConnectionInfo = connectionInfo ?? throw new ArgumentNullException(nameof(connectionInfo));
            this.Logger         = logger ?? throw new ArgumentNullException(nameof(logger));
            this.Context        = context;
        }
示例#3
0
 public static string GetApiUrl(this ITeamCityConnectionInfo connectionInfo)
 {
     return($"{connectionInfo.ServerUrl.TrimEnd('/')}/{(string.IsNullOrEmpty(connectionInfo.UserName) ? "guestAuth" : "httpAuth")}/");
 }
示例#4
0
 public TeamCityBuildQueuer(ITeamCityConnectionInfo connectionInfo, ILogSink logger)
 {
     this.ConnectionInfo = connectionInfo ?? throw new ArgumentNullException(nameof(connectionInfo));
     this.Logger         = logger ?? throw new ArgumentNullException(nameof(logger));
 }