public override async Task ExecuteAsync(IOperationExecutionContext context) { var github = new GitHubClient(this.ApiUrl, this.UserName, this.Password, this.OrganizationName); var data = new Dictionary <string, object> { ["title"] = this.Title }; if (!string.IsNullOrEmpty(this.Body)) { data.Add("body", this.Body); } if (this.Labels != null) { data.Add("labels", this.Labels); } if (this.Assignees != null) { data.Add("assignees", this.Assignees); } if (!string.IsNullOrEmpty(this.Milestone)) { data.Add("milestone", await github.CreateMilestoneAsync(this.Milestone, AH.CoalesceString(this.OrganizationName, this.UserName), this.RepositoryName, context.CancellationToken)); } this.IssueNumber = await github.CreateIssueAsync(AH.CoalesceString(this.OrganizationName, this.UserName), this.RepositoryName, data, context.CancellationToken).ConfigureAwait(false); }
public override async Task <IEnumerable <IIssueTrackerIssue> > EnumerateIssuesAsync(IIssueSourceEnumerationContext context) { var credentials = this.TryGetCredentials <GitLabCredentials>(); if (credentials == null) { throw new InvalidOperationException("Credentials must be supplied to enumerate GitLab issues."); } string projectName = AH.CoalesceString(this.ProjectName, credentials.ProjectName); if (string.IsNullOrEmpty(projectName)) { throw new InvalidOperationException("A project name must be defined in either the issue source or associated GitLab credentials in order to enumerate GitLab issues."); } var client = new GitLabClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.GroupName); var filter = new GitLabIssueFilter { Milestone = this.MilestoneTitle, Labels = this.Labels, CustomFilterQueryString = this.CustomFilterQueryString }; var issues = await client.GetIssuesAsync(projectName, filter, CancellationToken.None).ConfigureAwait(false); return(from i in issues select new GitLabIssue(i)); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("Close GitLab issue #", new Hilite(config[nameof(IssueId)])), new RichDescription("in ", new Hilite(AH.CoalesceString(config[nameof(ProjectName)], config[nameof(CredentialName)]))) )); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("HTTP ", AH.CoalesceString(config[nameof(this.Method)], "POST")), new RichDescription("to ", new Hilite(config[nameof(this.Url)])) )); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("Create issue titled ", new Hilite(config[nameof(Title)])), new RichDescription("in ", new Hilite(AH.CoalesceString(config[nameof(RepositoryName)], config[nameof(CredentialName)]))) )); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; if (string.IsNullOrEmpty(credentialName)) { return(Enumerable.Empty <string>()); } var credentials = ResourceCredentials.Create <GitLabCredentials>(credentialName); string ownerName = AH.CoalesceString(credentials.GroupName, credentials.UserName); string repositoryName = AH.CoalesceString(config["ProjectName"], credentials.ProjectName); if (string.IsNullOrEmpty(ownerName) || string.IsNullOrEmpty(repositoryName)) { return(Enumerable.Empty <string>()); } var client = new GitLabClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.GroupName); var milestones = await client.GetMilestonesAsync(repositoryName, "open", CancellationToken.None).ConfigureAwait(false); var titles = from m in milestones let title = m["title"]?.ToString() where !string.IsNullOrEmpty(title) select title; if (SDK.ProductName == "BuildMaster") { titles = new[] { "$ReleaseName", "$ReleaseNumber" }.Concat(titles); } return(titles); }
public static PackageDeploymentData Create(IOperationExecutionContext context, ILogSink log, string description) { string baseUrl = SDK.BaseUrl; if (string.IsNullOrEmpty(baseUrl)) { log.LogDebug("Deployment will not be recorded in ProGet because the System.BaseUrl configuration setting is not set."); return(null); } string serverName = AH.CoalesceString(context?.ServerName, Environment.MachineName); string relativeUrl; if (SDK.ProductName == "BuildMaster") { relativeUrl = context.ExpandVariables($"applications/{((IStandardContext)context).ProjectId}/builds/build?releaseNumber=$UrlEncode($ReleaseNumber)&buildNumber=$UrlEncode($PackageNumber)").AsString(); } else if (SDK.ProductName == "Hedgehog") { relativeUrl = "deployment-sets/details?deploymentSetId=" + ((IStandardContext)context).DeploymentSetId; } else { relativeUrl = "executions/execution-in-progress?executionId=" + context.ExecutionId; } return(new PackageDeploymentData(SDK.ProductName, baseUrl, relativeUrl, serverName, description)); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("Ensure milestone ", new Hilite(config[nameof(GitLabMilestoneConfiguration.Title)])), new RichDescription("in ", new Hilite(AH.CoalesceString(config[nameof(GitLabMilestoneConfiguration.ProjectName)], config[nameof(GitLabMilestoneConfiguration.CredentialName)]))) )); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { string ownerName = AH.CoalesceString(config[nameof(GitLabCredentials.GroupName)], config[nameof(GitLabCredentials.UserName)]); if (string.IsNullOrEmpty(ownerName)) { return(Enumerable.Empty <string>()); } GitLabClient client; try { client = new GitLabClient(config[nameof(GitLabCredentials.ApiUrl)], config[nameof(GitLabCredentials.UserName)], AH.CreateSecureString(config[nameof(GitLabCredentials.Password)].ToString()), config[nameof(GitLabCredentials.GroupName)]); } catch (InvalidOperationException) { return(Enumerable.Empty <string>()); } var repos = await client.GetProjectsAsync(CancellationToken.None).ConfigureAwait(false); var names = from m in repos let name = m["path_with_namespace"]?.ToString() where !string.IsNullOrEmpty(name) select name; return(names); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; if (string.IsNullOrEmpty(credentialName)) { return(Enumerable.Empty <string>()); } var credentials = ResourceCredentials.Create <GitHubCredentials>(credentialName); string ownerName = AH.CoalesceString(credentials.OrganizationName, credentials.UserName); string repositoryName = AH.CoalesceString(config["RepositoryName"], credentials.RepositoryName); if (string.IsNullOrEmpty(ownerName) || string.IsNullOrEmpty(repositoryName)) { return(Enumerable.Empty <string>()); } var client = new GitHubClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.OrganizationName); var milestones = await client.GetMilestonesAsync(ownerName, repositoryName, "open").ConfigureAwait(false); var titles = from m in milestones let title = m["title"]?.ToString() where !string.IsNullOrEmpty(title) select title; return(new[] { "$ReleaseName", "$ReleaseNumber" }.Concat(titles)); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; if (string.IsNullOrEmpty(credentialName)) { return(Enumerable.Empty <string>()); } var credentials = ResourceCredentials.Create <GitHubCredentials>(credentialName); string ownerName = AH.CoalesceString(credentials.OrganizationName, credentials.UserName); if (string.IsNullOrEmpty(ownerName)) { return(Enumerable.Empty <string>()); } var client = new GitHubClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.OrganizationName); var repos = await client.GetRepositoriesAsync().ConfigureAwait(false); var names = from m in repos let name = m["name"]?.ToString() where !string.IsNullOrEmpty(name) select name; return(new[] { "$ApplicationName" }.Concat(names)); }
internal static GitHubCredentials TryCreate(string name, IOperationConfiguration config) { int?projectId = AH.ParseInt(AH.CoalesceString(config["ProjectId"], config["ApplicationId"])); int?environmentId = AH.ParseInt(config["EnvironmentId"]); return((GitHubCredentials)ResourceCredentials.TryCreate(GitHubCredentials.TypeName, name, environmentId: environmentId, applicationId: projectId, inheritFromParent: false)); }
public static PackageDeploymentData Create(IOperationExecutionContext context, ILogSink log, string description) { string baseUrl = SDK.BaseUrl; if (string.IsNullOrEmpty(baseUrl)) { log.LogDebug("Deployment will not be recorded in ProGet because the System.BaseUrl configuration setting is not set."); return(null); } string serverName = AH.CoalesceString(context?.ServerName, Environment.MachineName); string relativeUrl; if (SDK.ProductName == "BuildMaster") { dynamic bmContext = context; relativeUrl = $"applications/{bmContext.ApplicationId}/builds/build?releaseNumber={Uri.EscapeDataString(bmContext.ReleaseNumber)}&buildNumber={Uri.EscapeDataString(bmContext.BuildNumber)}"; } else { relativeUrl = "/deployment-sets/details?deploymentSetId=" + ((IStandardContext)context).DeploymentSetId; } return(new PackageDeploymentData(SDK.ProductName, baseUrl, relativeUrl, serverName, description)); }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; var jobName = config["JobName"]; if (string.IsNullOrEmpty(credentialName) || string.IsNullOrEmpty(jobName)) { return(Enumerable.Empty <string>()); } int?projectId = AH.ParseInt(AH.CoalesceString(config["ProjectId"], config["ApplicationId"])); int?environmentId = AH.ParseInt(config["EnvironmentId"]); var credentials = (JenkinsLegacyCredentials)ResourceCredentials.TryCreate(JenkinsLegacyCredentials.TypeName, credentialName, environmentId: environmentId, applicationId: projectId, inheritFromParent: false); if (credentials == null) { return(Enumerable.Empty <string>()); } using (var cts = new CancellationTokenSource(new TimeSpan(0, 0, 30))) { var client = this.CreateClient(config, cts.Token); return(await client.GetBranchNamesAsync(jobName).ConfigureAwait(false)); } }
public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config) { var credentialName = config["CredentialName"]; if (string.IsNullOrEmpty(credentialName)) { return(Enumerable.Empty <string>()); } var credentials = ResourceCredentials.Create <GitLabCredentials>(credentialName); string ownerName = AH.CoalesceString(credentials.GroupName, credentials.UserName); if (string.IsNullOrEmpty(ownerName)) { return(Enumerable.Empty <string>()); } var client = new GitLabClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.GroupName); var groups = await client.GetGroupsAsync(CancellationToken.None).ConfigureAwait(false); var names = from m in groups let name = m["full_path"]?.ToString() where !string.IsNullOrEmpty(name) select name; return(names); }
public ActiveDirectoryUser(UserId userId, string displayName, string emailAddress) { this.UserName = userId.Principal; this.Domain = userId.DomainAlias; this.DisplayName = AH.CoalesceString(displayName, this.UserName); this.EmailAddress = emailAddress; this.principalName = $"{userId.Principal}@{userId.DomainAlias}"; }
public override async Task ConfigureAsync(IOperationExecutionContext context) { var github = new GitHubClient(this.Template.ApiUrl, this.Template.UserName, this.Template.Password, this.Template.OrganizationName); var ownerName = AH.CoalesceString(this.Template.OrganizationName, this.Template.UserName); await github.EnsureReleaseAsync(ownerName, this.Template.RepositoryName, this.Template.Tag, this.Template.Target, this.Template.Title, this.Template.Description, this.Template.Draft, this.Template.Prerelease, context.CancellationToken).ConfigureAwait(false); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("Run DFHack test suite"), new RichDescription("for ", new Hilite(AH.CoalesceString(config[nameof(OperatingSystem)], "unknown operating system")), " (", new Hilite(AH.CoalesceString(config[nameof(Architecture)], "unknown architecture")), ")") )); }
public SvnClient(UsernamePasswordCredentials credentials, Agent agent, string svnExePath, ILogSink log, CancellationToken?cancellationToken = null) { this.execOps = new Lazy <IRemoteProcessExecuter>(() => agent.GetService <IRemoteProcessExecuter>()); this.userName = credentials?.UserName; this.password = credentials?.Password; this.svnExePath = AH.CoalesceString(svnExePath, RemoteMethods.GetEmbeddedSvnExePath(agent)); this.log = log ?? (ILogSink)Logger.Null; this.cancellationToken = cancellationToken ?? CancellationToken.None; }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { string source = AH.CoalesceString(config[nameof(this.RepositoryUrl)], config[nameof(this.CredentialName)]); return(new ExtendedRichDescription( new RichDescription("Get Git Source"), new RichDescription("from ", new Hilite(source), " to ", new DirectoryHilite(config[nameof(this.DiskPath)])) )); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { string source = AH.CoalesceString(config[nameof(this.RepositoryName)], config[nameof(this.CredentialName)]); return(new ExtendedRichDescription( new RichDescription("Upload ", new MaskHilite(config[nameof(this.Includes)], config[nameof(this.Excludes)]), " from ", new DirectoryHilite(config[nameof(this.SourceDirectory)]), " to GitHub"), new RichDescription("in ", new Hilite(source), " release ", new Hilite(config[nameof(this.Tag)])) )); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { string source = AH.CoalesceString(config[nameof(this.Template.RepositoryName)], config[nameof(this.Template.CredentialName)]); return(new ExtendedRichDescription( new RichDescription("Ensure GitHub Release"), new RichDescription("in ", new Hilite(source), " for tag ", new Hilite(config[nameof(this.Template.Tag)])) )); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { string source = AH.CoalesceString(config[nameof(this.RepositoryName)], config[nameof(this.CredentialName)]); return(new ExtendedRichDescription( new RichDescription("Tag GitHub Source"), new RichDescription("in ", new Hilite(source), " with ", new Hilite(config[nameof(this.Tag)])) )); }
public override async Task <IEnumerable <IIssueTrackerIssue> > EnumerateIssuesAsync(IIssueSourceEnumerationContext context) { GitHubCredentials credentials = null; if (context is IStandardContext stdcontext) { credentials = this.TryGetCredentials(stdcontext.EnvironmentId, stdcontext.ProjectId) as GitHubCredentials; } else { credentials = this.TryGetCredentials(); } if (credentials == null) { throw new InvalidOperationException("Credentials must be supplied to enumerate GitHub issues."); } string repositoryName = AH.CoalesceString(this.RepositoryName, credentials.RepositoryName); if (string.IsNullOrEmpty(repositoryName)) { throw new InvalidOperationException("A repository name must be defined in either the issue source or associated GitHub credentials in order to enumerate GitHub issues."); } var client = new GitHubClient(credentials.ApiUrl, credentials.UserName, credentials.Password, credentials.OrganizationName); string ownerName = AH.CoalesceString(credentials.OrganizationName, credentials.UserName); var filter = new GitHubIssueFilter { Labels = this.Labels, CustomFilterQueryString = this.CustomFilterQueryString }; if (!string.IsNullOrEmpty(this.MilestoneTitle)) { int?milestoneId = await client.FindMilestoneAsync(this.MilestoneTitle, ownerName, repositoryName, CancellationToken.None).ConfigureAwait(false); if (milestoneId == null) { throw new InvalidOperationException($"Milestone '{this.MilestoneTitle}' not found in repository '{repositoryName}' owned by '{ownerName}'."); } filter.Milestone = milestoneId.ToString(); } else { filter.Milestone = "*"; } var issues = await client.GetIssuesAsync(ownerName, repositoryName, filter, CancellationToken.None).ConfigureAwait(false); return(from i in issues select new GitHubIssue(i)); }
void IVariableSetter <SelectBuildConfigurationVariable> .BindToVariable(SelectBuildConfigurationVariable variable, string defaultValue) { if (variable == null) { throw new ArgumentNullException("variable"); } this.FillItems(TeamCityConfigurer.GetConfigurer(variable.ConfigurationProfileName)); this.SelectedValue = AH.CoalesceString(variable.Value, defaultValue); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription("Add comment to GitHub issue #", new Hilite(config[nameof(IssueNumber)])), new RichDescription( "in ", new Hilite(AH.CoalesceString(config[nameof(RepositoryName)], config[nameof(CredentialName)])), " starting with ", new Hilite(config[nameof(Body)]) ) )); }
public override RichDescription GetDescription() { return(new RichDescription( "Ensure drift status is ", new Hilite(this.Status.ToString()), " for ", !string.IsNullOrEmpty(this.Server) ? "server " : "role ", new Hilite(AH.CoalesceString(this.Server, this.Role)) )); }
public async Task StoreConfigurationStatusAsync(ConfigurationPersistenceContext context) { for (int i = 0; i < this.scriptResults.Configuration?.Count; i++) { await context.SetConfigurationStatusAsync( AH.CoalesceString(this.scriptResults.Configuration[i].ConfigType, "PSConfig"), this.scriptResults.Configuration[i].ConfigKey, this.comparisonResults[i] == null?ConfigurationStatus.Current : ConfigurationStatus.Drifted); } }
public override RichDescription GetDescription() { return(new RichDescription( "Versions of ", new Hilite(this.PackageId), " from ", new Hilite(AH.CoalesceString(this.FeedUrl, this.CredentialName)), "." )); }
public override BuildImporterBase CreateFromForm() { string buildNumber = AH.CoalesceString(this.Template.BuildNumber, this.txtBuildNumber.Text, "lastSuccessfulBuild"); return(new JenkinsBuildImporter { ArtifactName = this.Template.ArtifactName ?? this.Template.JobName, BuildNumber = buildNumber, JobName = this.Template.JobName }); }