public static TfsTeamProjectCollection GetTeamProjectCollection(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { TfsTeamProjectCollection result; TfsClientCredentials credential = null; if (tfsCredentials != null) { credential = tfsCredentials.GetCredentials(); } else { if (Defaults.GetDefaultCredentials(tfsCollectionUri) != null) { credential = Defaults.GetDefaultCredentials(tfsCollectionUri).GetCredentials(); } } if (credential != null) { result = new TfsTeamProjectCollection(tfsCollectionUri, credential); result.Connect(ConnectOptions.IncludeServices); } else { result = new TfsTeamProjectCollection(tfsCollectionUri); } return result; }
/// <summary> /// Returns the <see cref="VssCredentials"/> corresponding to a <see cref="ITfsCredentials"/> object. /// </summary> /// <param name="credentials"><see cref="ITfsCredentials"/> credential instance.</param> /// <returns><see cref="VssCredentials"/> instance.</returns> public static VssCredentials ToVssCredentials(this ITfsCredentials credentials) { credentials.NotNull(nameof(credentials)); switch (credentials.GetType().Name) { case nameof(TfsNtlmCredentials): return(new VssCredentials()); case nameof(TfsBasicCredentials): var basicCredentials = (TfsBasicCredentials)credentials; return(new VssBasicCredential(basicCredentials.UserName, basicCredentials.Password)); case nameof(TfsOAuthCredentials): var oAuthCredentials = (TfsOAuthCredentials)credentials; return(new VssOAuthAccessTokenCredential(oAuthCredentials.AccessToken)); case nameof(TfsAadCredentials): var aadCredentials = (TfsAadCredentials)credentials; return(new VssAadCredential(aadCredentials.UserName, aadCredentials.Password)); default: throw new PullRequestIssuesException("Unknown credential type."); } }
public GitHttpClient CreateGitClient(Uri collectionUrl, ITfsCredentials credentials, out Identity identity) { identity = new Identity { ProviderDisplayName = "FakeUser", Id = Guid.NewGuid(), IsActive = true }; return(this.CreateGitClient(collectionUrl, credentials)); }
/// <summary> /// Initializes a new instance of the <see cref="TfsPullRequestSettings"/> class. /// </summary> /// <param name="repositoryUrl">Full URL of the Git repository, /// eg. <code>http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository</code>. /// Supported URL schemes are HTTP, HTTPS and SSH. /// URLs using SSH scheme are converted to HTTPS.</param> /// <param name="pullRequestId">ID of the pull request.</param> /// <param name="credentials">Credentials to use to authenticate against Team Foundation Server or /// Azure DevOps.</param> public TfsPullRequestSettings(Uri repositoryUrl, int pullRequestId, ITfsCredentials credentials) : base(repositoryUrl, credentials) { pullRequestId.NotNegativeOrZero(nameof(pullRequestId)); this.PullRequestId = pullRequestId; }
/// <summary> /// Initializes a new instance of the <see cref="TeamProjects" /> class. /// </summary> /// <param name="tfsCollectionUri">The TFS collection URI.</param> /// <param name="tfsCredentials">The TFS credentials.</param> public TeamProjects(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { this._tfsCollectionUri = tfsCollectionUri; this._tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsCollectionUri, tfsCredentials); this._registration = (IRegistration)this._tfsTeamProjectCollection.GetService(typeof(IRegistration)); this._commonStructureService = this._tfsTeamProjectCollection.GetService <ICommonStructureService>(); }
/// <summary> /// Initializes a new instance of the <see cref="BaseTfsPullRequestSettings"/> class. /// </summary> /// <param name="repositoryUrl">Full URL of the Git repository, /// eg. <code>http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository</code>. /// Supported URL schemes are HTTP, HTTPS and SSH. /// URLs using SSH scheme are converted to HTTPS.</param> /// <param name="credentials">Credentials to use to authenticate against Team Foundation Server or /// Azure DevOps.</param> protected BaseTfsPullRequestSettings(Uri repositoryUrl, ITfsCredentials credentials) { repositoryUrl.NotNull(nameof(repositoryUrl)); credentials.NotNull(nameof(credentials)); this.RepositoryUrl = repositoryUrl; this.Credentials = credentials; }
/// <summary> /// Initializes a new instance of the <see cref="TeamProjects" /> class. /// </summary> /// <param name="tfsCollectionUri">The TFS collection URI.</param> /// <param name="tfsCredentials">The TFS credentials.</param> public TeamProjects(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { this._tfsCollectionUri = tfsCollectionUri; this._tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsCollectionUri, tfsCredentials); this._registration = (IRegistration)this._tfsTeamProjectCollection.GetService(typeof(IRegistration)); this._commonStructureService = this._tfsTeamProjectCollection.GetService<ICommonStructureService>(); }
public TeamProjectCollections(Uri tfsUri, ITfsCredentials tfsCredentials) { this._tfsUri = tfsUri; this._tfsCredentials = tfsCredentials; this._tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri, this._tfsCredentials); this._tfsConfigurationServer = this._tfsTeamProjectCollection.GetConfigurationServer(); this._registration = (IRegistration)this._tfsTeamProjectCollection.GetService(typeof(IRegistration)); this._teamProjectCollectionService = this._tfsConfigurationServer.GetService <ITeamProjectCollectionService>(); }
public ProcessTemplates(Uri collectionUri, ITfsCredentials tfsCredentials = null) { this._collectionUri = collectionUri; this._tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(this._collectionUri, tfsCredentials); this._teamProjectCollectionService = this._tfsTeamProjectCollection.GetConfigurationServer().GetService <ITeamProjectCollectionService>(); this._teamProjectCollection = this._teamProjectCollectionService.GetCollection(this._tfsTeamProjectCollection.InstanceId); }
public TeamProjectCollections(Uri tfsUri, ITfsCredentials tfsCredentials) { this._tfsUri = tfsUri; this._tfsCredentials = tfsCredentials; this._tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri, this._tfsCredentials); this._tfsConfigurationServer = this._tfsTeamProjectCollection.GetConfigurationServer(); this._registration = (IRegistration)this._tfsTeamProjectCollection.GetService(typeof(IRegistration)); this._teamProjectCollectionService = this._tfsConfigurationServer.GetService<ITeamProjectCollectionService>(); }
public ProcessTemplates(Uri collectionUri, ITfsCredentials tfsCredentials = null) { this._collectionUri = collectionUri; this._tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(this._collectionUri, tfsCredentials); this._teamProjectCollectionService = this._tfsTeamProjectCollection.GetConfigurationServer().GetService<ITeamProjectCollectionService>(); this._teamProjectCollection = this._teamProjectCollectionService.GetCollection(this._tfsTeamProjectCollection.InstanceId); }
public void Should_Throw_If_Credentials_Are_Null() { // Given ITfsCredentials credentials = null; // When var result = Record.Exception(() => credentials.ToVssCredentials()); // Then result.IsArgumentNullException("credentials"); }
/// <summary> /// Returns credentials for authentication with a personal access token. /// Can be used for Team Foundation Server and Visual Studio Team Services. /// </summary> /// <param name="personalAccessToken">Personal access token.</param> /// <returns>Same object instance.</returns> public AutoMergeCredentials AuthenticationPersonalAccessToken(string personalAccessToken) { if (String.IsNullOrWhiteSpace(personalAccessToken)) { throw new ArgumentNullException(nameof(personalAccessToken)); } _log?.Information("Using Personal Access Token authentication."); Credentials = new TfsBasicCredentials(String.Empty, personalAccessToken); return(this); }
/// <summary> /// Returns credentials for OAuth authentication. /// Can only be used with Visual Studio Team Services. /// </summary> /// <param name="accessToken">OAuth access token.</param> /// <returns>Same object instance.</returns> public AutoMergeCredentials AuthenticationOAuth(string accessToken) { if (String.IsNullOrWhiteSpace(accessToken)) { throw new ArgumentNullException(nameof(accessToken)); } _log?.Information("Using OAuth authentication."); Credentials = new TfsOAuthCredentials(accessToken); return(this); }
public static ITfsCredentials GetDefaultCredentials(Uri tfsUri) { ITfsCredentials result = null; if (_tfsCredentials.ContainsKey(tfsUri)) { result = _tfsCredentials[tfsUri]; } return(result); }
public void Should_Throw_If_Credentials_Are_Null() { // Given ITfsCredentials creds = null; // When var result = Record.Exception(() => new TfsPullRequestSettings(creds)); // Then result.IsArgumentNullException("credentials"); }
public static IPullRequestSystem TfsPullRequests( this ICakeContext context, Uri repositoryUrl, int pullRequestId, ITfsCredentials credentials) { context.NotNull(nameof(context)); repositoryUrl.NotNull(nameof(repositoryUrl)); credentials.NotNull(nameof(credentials)); return(context.TfsPullRequests(new TfsPullRequestSystemSettings(repositoryUrl, pullRequestId, credentials))); }
public static IPullRequestSystem TfsPullRequests( this ICakeContext context, Uri repositoryUrl, string sourceBranch, ITfsCredentials credentials) { context.NotNull(nameof(context)); repositoryUrl.NotNull(nameof(repositoryUrl)); sourceBranch.NotNullOrWhiteSpace(nameof(sourceBranch)); credentials.NotNull(nameof(credentials)); return(context.TfsPullRequests(new TfsPullRequestSystemSettings(repositoryUrl, sourceBranch, credentials))); }
public void Should_Throw_If_Credentials_Are_Null() { // Given var repositoryUrl = new Uri("http://example.com"); var sourceBranch = "foo"; ITfsCredentials credentials = null; // When var result = Record.Exception(() => new TfsPullRequestSettings(repositoryUrl, sourceBranch, credentials)); // Then result.IsArgumentNullException("credentials"); }
public override GitHttpClient CreateGitClient(Uri collectionUrl, ITfsCredentials credentials) { var mock = new Mock <GitHttpClient>(MockBehavior.Loose, collectionUrl, credentials.ToVssCredentials()); mock.Setup(arg => arg.GetPullRequestAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), null, null, null, null, null, null, default(CancellationToken))) .ReturnsAsync(() => null); mock.Setup(arg => arg.GetPullRequestsAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <GitPullRequestSearchCriteria>(), null, null, 1, null, default(CancellationToken))) .ReturnsAsync(() => new List <GitPullRequest>()); mock = this.Setup(mock); return(mock.Object); }
public static ITeamProjects CreateTeamProjectMananger(Uri tfsCollectionUri, ITfsCredentials tfsCredentials = null) { ITeamProjects result; if (TeamProjectManagers.ContainsKey(tfsCollectionUri)) { result = TeamProjectManagers[tfsCollectionUri]; } else { result = new TeamProjects(tfsCollectionUri, tfsCredentials); TeamProjectManagers.AddOrUpdate(tfsCollectionUri, result, (key, oldValue) => result); } return result; }
public static IIterationManager GetManager(ProjectDetail projectDetail, ITfsCredentials tfsCredentials = null) { IIterationManager result; if (IterationManagers.FirstOrDefault(o => o.Key.CollectionUri == projectDetail.CollectionUri && o.Key.ProjectName == projectDetail.ProjectName).Value != null) { result = IterationManagers.FirstOrDefault(o => o.Key.CollectionUri == projectDetail.CollectionUri && o.Key.ProjectName == projectDetail.ProjectName).Value; } else { result = new IterationManager(projectDetail, tfsCredentials); IterationManagers.AddOrUpdate(projectDetail, result, (key, oldValue) => result); } return result; }
public static IAreaManager GetManager(ProjectDetail projectDetail, ITfsCredentials tfsCredentials = null) { IAreaManager result; if (AreaManagers.FirstOrDefault(o => o.Key.CollectionUri == projectDetail.CollectionUri && o.Key.ProjectName == projectDetail.ProjectName).Value != null) { result = AreaManagers.FirstOrDefault(o => o.Key.CollectionUri == projectDetail.CollectionUri && o.Key.ProjectName == projectDetail.ProjectName).Value; } else { result = new AreaManager(projectDetail, tfsCredentials); AreaManagers.AddOrUpdate(projectDetail, result, (key, oldValue) => result); } return result; }
/// <summary> /// Returns credentials for basic authentication. /// Can only be used for on-premise Team Foundation Server configured for basic authentication. /// See https://www.visualstudio.com/en-us/docs/integrate/get-started/auth/tfs-basic-auth. /// </summary> /// <param name="userName">User name.</param> /// <param name="password">Password.</param> /// <returns>Same object instance.</returns> public AutoMergeCredentials AuthenticationBasic(string userName, string password) { if (String.IsNullOrWhiteSpace(userName)) { throw new ArgumentNullException(nameof(userName)); } if (String.IsNullOrWhiteSpace(password)) { throw new ArgumentNullException(nameof(password)); } _log?.Information("Using Basic authentication."); Credentials = new TfsBasicCredentials(userName, password); return(this); }
public static IProcessTemplates CreateProcessTemplateMananger(Uri tfsCollectionUri, ITfsCredentials tfsCredentials = null) { IProcessTemplates result; if (ProcessTemplateManagers.ContainsKey(tfsCollectionUri)) { result = ProcessTemplateManagers[tfsCollectionUri]; } else { result = new ProcessTemplates(tfsCollectionUri, tfsCredentials); ProcessTemplateManagers.AddOrUpdate(tfsCollectionUri, result, (key, oldValue) => result); } return result; }
/// <summary> /// Initializes a new instance of the <see cref="TfsCreatePullRequestSettings"/> class. /// </summary> /// <param name="repositoryUrl">Full URL of the Git repository, /// eg. <code>http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository</code>. /// Supported URL schemes are HTTP, HTTPS and SSH. /// URLs using SSH scheme are converted to HTTPS.</param> /// <param name="sourceRefName">Branch for which the pull request is made.</param> /// <param name="targetRefName">Target branch of the pull request. /// If <see langword="null"/> or <see cref="string.Empty"/> the default branch of the repository will be used.</param> /// <param name="title">Title of the pull request.</param> /// <param name="description">Description of the pull request.</param> /// <param name="credentials">Credentials to use to authenticate against Team Foundation Server or /// Azure DevOps.</param> public TfsCreatePullRequestSettings( Uri repositoryUrl, string sourceRefName, string targetRefName, string title, string description, ITfsCredentials credentials) : base(repositoryUrl, sourceRefName, credentials) { title.NotNullOrWhiteSpace(nameof(title)); description.NotNull(nameof(description)); this.TargetRefName = targetRefName; this.Title = title; this.Description = description; }
/// <summary> /// Initializes a new instance of the <see cref="BaseTfsPullRequestSettings"/> class using environment variables /// as set by a Azure Pipelines or Team Foundation Server build. /// </summary> /// <param name="credentials">Credentials to use to authenticate against Team Foundation Server or /// Azure DevOps.</param> protected BaseTfsPullRequestSettings(ITfsCredentials credentials) { credentials.NotNull(nameof(credentials)); this.Credentials = credentials; var repositoryUrl = Environment.GetEnvironmentVariable("BUILD_REPOSITORY_URI", EnvironmentVariableTarget.Process); if (string.IsNullOrWhiteSpace(repositoryUrl)) { throw new InvalidOperationException( "Failed to read the BUILD_REPOSITORY_URI environment variable. Make sure you are running in an Azure Pipelines or Team Foundation Server build."); } this.RepositoryUrl = new Uri(repositoryUrl); }
/// <summary> /// Creates a client object for communicating with Team Foundation Server or Azure DevOps. /// </summary> /// <param name="collectionUrl">The URL of the TFS/Azure DevOps team project collection.</param> /// <param name="credentials">The credentials to connect to TFS/Azure DevOps.</param> /// <param name="authorizedIdentity">Returns identity which is authorized.</param> /// <returns>Client object for communicating with Team Foundation Server or Azure DevOps.</returns> public GitHttpClient CreateGitClient(Uri collectionUrl, ITfsCredentials credentials, out Identity authorizedIdentity) { var connection = new VssConnection(collectionUrl, credentials.ToVssCredentials()); authorizedIdentity = connection.AuthorizedIdentity; var gitClient = connection.GetClient <GitHttpClient>(); if (gitClient == null) { throw new TfsException("Could not retrieve the GitHttpClient object"); } return(gitClient); }
public static ITeamProjects CreateTeamProjectMananger(Uri tfsCollectionUri, ITfsCredentials tfsCredentials = null) { ITeamProjects result; if (TeamProjectManagers.ContainsKey(tfsCollectionUri)) { result = TeamProjectManagers[tfsCollectionUri]; } else { result = new TeamProjects(tfsCollectionUri, tfsCredentials); TeamProjectManagers.AddOrUpdate(tfsCollectionUri, result, (key, oldValue) => result); } return(result); }
public AreaManager(ProjectDetail projectDetail, ITfsCredentials tfsCredentials) { this.projectDetail = projectDetail; this.tfsTeamProjectCollection = TfsApi.Administration.TfsTeamProjectCollectionFactory.GetTeamProjectCollection(this.projectDetail.CollectionUri, tfsCredentials); this.teamConfig = this.tfsTeamProjectCollection.GetService<TeamSettingsConfigurationService>(); this.commonStructureService = (ICommonStructureService4)this.tfsTeamProjectCollection.GetService(typeof(ICommonStructureService4)); this.projectInfo = this.commonStructureService.GetProjectFromName(this.projectDetail.ProjectName); foreach (TeamConfiguration item in this.teamConfig.GetTeamConfigurationsForUser(new[] { this.projectInfo.Uri })) { this.teamConfiguration = item; break; } }
public AreaManager(ProjectDetail projectDetail, ITfsCredentials tfsCredentials) { this.projectDetail = projectDetail; this.tfsTeamProjectCollection = TfsApi.Administration.TfsTeamProjectCollectionFactory.GetTeamProjectCollection(this.projectDetail.CollectionUri, tfsCredentials); this.teamConfig = this.tfsTeamProjectCollection.GetService <TeamSettingsConfigurationService>(); this.commonStructureService = (ICommonStructureService4)this.tfsTeamProjectCollection.GetService(typeof(ICommonStructureService4)); this.projectInfo = this.commonStructureService.GetProjectFromName(this.projectDetail.ProjectName); foreach (TeamConfiguration item in this.teamConfig.GetTeamConfigurationsForUser(new[] { this.projectInfo.Uri })) { this.teamConfiguration = item; break; } }
public void Should_Throw_If_Credentials_Are_Null() { // Given var repositoryUrl = new Uri("http://example.com"); var sourceRefName = "foo"; var targetRefName = "master"; var title = "foo"; var description = "bar"; ITfsCredentials credentials = null; // When var result = Record.Exception(() => new TfsCreatePullRequestSettings(repositoryUrl, sourceRefName, targetRefName, title, description, credentials)); // Then result.IsArgumentNullException("credentials"); }
/// <summary> /// Initializes a new instance of the <see cref="TfsPullRequestSettings"/> class using environment variables /// as set by a Azure Pipelines or Team Foundation Server build. /// </summary> /// <param name="credentials">Credentials to use to authenticate against Team Foundation Server or /// Azure DevOps.</param> public TfsPullRequestSettings(ITfsCredentials credentials) : base(credentials) { var pullRequestId = Environment.GetEnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID", EnvironmentVariableTarget.Process); if (string.IsNullOrWhiteSpace(pullRequestId)) { throw new InvalidOperationException( "Failed to read the SYSTEM_PULLREQUEST_PULLREQUESTID environment variable. Make sure you are running in an Azure Pipelines or Team Foundation Server build."); } if (!int.TryParse(pullRequestId, out int pullRequestIdValue)) { throw new InvalidOperationException("SYSTEM_PULLREQUEST_PULLREQUESTID environment variable should contain integer value"); } if (pullRequestIdValue <= 0) { throw new InvalidOperationException("SYSTEM_PULLREQUEST_PULLREQUESTID environment variable should contain integer value and it should be greater than zero"); } this.PullRequestId = pullRequestIdValue; }
/// <summary> /// Returns the <see cref="VssCredentials"/> corresponding to a <see cref="ITfsCredentials"/> object. /// </summary> /// <param name="credentials"><see cref="ITfsCredentials"/> credential instance.</param> /// <returns><see cref="VssCredentials"/> instance.</returns> public static VssCredentials ToVssCredentials(this ITfsCredentials credentials) { if (credentials == null) { throw new ArgumentNullException(nameof(credentials)); } switch (credentials.GetType().Name) { case nameof(TfsNtlmCredentials): return(new VssCredentials()); case nameof(TfsBasicCredentials): var basicCredentials = (TfsBasicCredentials)credentials; return(new VssBasicCredential(basicCredentials.UserName, basicCredentials.Password)); case nameof(TfsOAuthCredentials): var oAuthCredentials = (TfsOAuthCredentials)credentials; return(new VssOAuthAccessTokenCredential(oAuthCredentials.AccessToken)); default: throw new InvalidOperationException("Not supported credential type."); } }
public TfsTeam(ITfsCredentials credentials) { tfsCredentials = credentials; }
public static void GetDefaultVisualStudioEnvironment(Uri tfsUri, ITfsCredentials tfsCredentials) { _tfsCredentials.AddOrUpdate(tfsUri, tfsCredentials, (key, oldValue) => tfsCredentials); }
public static void SetDefaultCredentials(Uri tfsUri, ITfsCredentials tfsCredentials) { _tfsCredentials.AddOrUpdate(tfsUri, tfsCredentials, (key, oldValue) => tfsCredentials); }
public TestSuiteManager(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { // TODO: Complete member initialization this._tfsCollectionUri = tfsCollectionUri; this._tfsCredentials = tfsCredentials; }
public TestSuiteManager(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { // TODO: Complete member initialization this._tfsCollectionUri = tfsCollectionUri; this._tfsCredentials = tfsCredentials; }
/// <summary> /// Initializes a new instance of the <see cref="TfsPullRequest"/> class. /// </summary> /// <param name="log">The Cake log context.</param> /// <param name="settings">Settings for accessing TFS.</param> /// <param name="gitClientFactory">A factory to communicate with Git client.</param> /// <exception cref="TfsPullRequestNotFoundException">If <see cref="TfsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> /// is set to <c>true</c> and no pull request could be found.</exception> public TfsPullRequest(ICakeLog log, TfsPullRequestSettings settings, IGitClientFactory gitClientFactory) { log.NotNull(nameof(log)); settings.NotNull(nameof(settings)); gitClientFactory.NotNull(nameof(gitClientFactory)); this.log = log; this.gitClientFactory = gitClientFactory; this.credentials = settings.Credentials; this.throwExceptionIfPullRequestCouldNotBeFound = settings.ThrowExceptionIfPullRequestCouldNotBeFound; this.repositoryDescription = new RepositoryDescription(settings.RepositoryUrl); this.log.Verbose( "Repository information:\n CollectionName: {0}\n CollectionUrl: {1}\n ProjectName: {2}\n RepositoryName: {3}", this.repositoryDescription.CollectionName, this.repositoryDescription.CollectionUrl, this.repositoryDescription.ProjectName, this.repositoryDescription.RepositoryName); using (var gitClient = this.gitClientFactory.CreateGitClient(this.repositoryDescription.CollectionUrl, settings.Credentials, out var authorizedIdenity)) { this.log.Verbose( "Authorized Identity:\n Id: {0}\n DisplayName: {1}", authorizedIdenity.Id, authorizedIdenity.DisplayName); if (settings.PullRequestId.HasValue) { this.log.Verbose("Read pull request with ID {0}", settings.PullRequestId.Value); this.pullRequest = gitClient.GetPullRequestAsync( this.repositoryDescription.ProjectName, this.repositoryDescription.RepositoryName, settings.PullRequestId.Value).Result; } else if (!string.IsNullOrWhiteSpace(settings.SourceRefName)) { this.log.Verbose("Read pull request for branch {0}", settings.SourceRefName); var pullRequestSearchCriteria = new GitPullRequestSearchCriteria() { Status = Microsoft.TeamFoundation.SourceControl.WebApi.PullRequestStatus.Active, SourceRefName = settings.SourceRefName, }; this.pullRequest = gitClient.GetPullRequestsAsync( this.repositoryDescription.ProjectName, this.repositoryDescription.RepositoryName, pullRequestSearchCriteria, top: 1).Result.SingleOrDefault(); } else { throw new ArgumentOutOfRangeException( nameof(settings), "Either PullRequestId or SourceRefName needs to be set"); } } if (this.pullRequest == null) { if (this.throwExceptionIfPullRequestCouldNotBeFound) { throw new TfsPullRequestNotFoundException("Pull request not found"); } this.log.Warning("Could not find pull request"); return; } this.log.Verbose( "Pull request information:\n PullRequestId: {0}\n RepositoryId: {1}\n RepositoryName: {2}\n SourceRefName: {3}", this.pullRequest.PullRequestId, this.pullRequest.Repository.Id, this.pullRequest.Repository.Name, this.pullRequest.SourceRefName); }
public TfsTeam(ITfsCredentials credentials) { tfsCredentials = credentials; }
/// <summary> /// Returns credentials for integrated / NTLM authentication. /// Can only be used for on-premise Team Foundation Server. /// </summary> /// <returns>Same object instance.</returns> public AutoMergeCredentials AuthenticationNtlm() { _log?.Information("Using NTML authentication."); Credentials = new TfsNtlmCredentials(); return(this); }