/// <summary> /// Tries to detect the Azure DevOps / TFS project home page url from a repository url of the same project. /// </summary> /// <param name="remoteUrl"> /// The url of the repository to find the Azure DevOps / TFS project url for. /// </param> /// <returns> /// A tuple that contains whether a Azure DevOps / TFS project could be recognized from the given url and the resulting home page url of the project. /// </returns> public static (bool success, string projectUrl) TryDetectProjectFromRemoteUrl(string remoteUrl) { if (remoteUrl is null && !BuildServerSettingsHelper.IsUrlValid(remoteUrl)) { return(false, null); } return(TryTransformString(remoteUrl, RemoteToProjectUrlLookup)); }
/// <summary> /// Tries to get the token management url of the Azure DevOps / TFS instance for a given project url, without testing /// whether <paramref name="projectUrl"/> actually points to a Azure DevOps / TFS instance. /// </summary> /// <remarks> /// TryGetTokenManagementUrlFromProject will happlily convert anything that somewhat looks like a project url /// in favor of better availability for on premise installations of TFS /// </remarks> /// <param name="projectUrl"> /// The url to the home page of a Azure DevOps / TFS project. /// </param> /// <returns> /// A tuple that contains whether the token management url could be recognized from the given project url and the resulting url. /// </returns> public static (bool success, string tokenManagementUrl) TryGetTokenManagementUrlFromProject(string projectUrl) { if (projectUrl is null && !BuildServerSettingsHelper.IsUrlValid(projectUrl)) { return(false, null); } return(TryTransformString(projectUrl, ProjectToTokenManagementUrlLookup)); }
/// <summary> /// Tries to parse a url to a Azure DevOps / TFS build result and get the corresponding project and build id from. /// </summary> /// <param name="buildUrl"> /// A url that points to the build status / build results page of a build in a Azure DevOps / TFS project /// </param> /// <returns> /// A tuple that contains whether the project and build id could be detected from the given url, as well as both informations. /// </returns> public static (bool success, string projectUrl, int buildId) TryParseBuildUrl(string buildUrl) { if (buildUrl is null && !BuildServerSettingsHelper.IsUrlValid(buildUrl)) { return(false, null, -1); } var match = BuildUrlInfoRegex.Match(buildUrl); if (match.Success) { var projectUrl = match.Groups["projecturl"].Value; if (int.TryParse(match.Groups["buildid"].Value, out var buildId)) { return(true, projectUrl, buildId); } } return(false, "", -1); }
private void UpdateView() { if (_isUpdating) { return; } _isUpdating = true; try { TfsServer.Text = _currentSettings.ProjectUrl; TfsBuildDefinitionNameFilter.Text = _currentSettings.BuildDefinitionFilter; labelRegexError.Visible = !BuildServerSettingsHelper.IsRegexValid(TfsBuildDefinitionNameFilter.Text); RestApiToken.Text = _currentSettings.ApiToken; TokenManagementLink.Enabled = BuildServerSettingsHelper.IsUrlValid(TokenManagementUrl); } finally { _isUpdating = false; } }
private void EnableRestApiLink() { _tokenManagementUrl = $"{TfsServer.Text}_details/security/tokens"; RestApiTokenLink.Enabled = BuildServerSettingsHelper.IsUrlValid(_tokenManagementUrl); }