public SuccessOrErrorResult <WorkItemLink[]> Map(OctopusPackageMetadata packageMetadata) { if (!IsEnabled || string.IsNullOrEmpty(store.GetJiraUsername()) || string.IsNullOrEmpty(store.GetJiraPassword())) { return(null); } var baseUrl = store.GetBaseUrl(); if (string.IsNullOrWhiteSpace(baseUrl)) { return(null); } var releaseNotePrefix = store.GetReleaseNotePrefix(); var workItemIds = commentParser.ParseWorkItemIds(packageMetadata).Distinct(); return(workItemIds.Select(workItemId => { var issue = jira.Value.GetIssue(workItemId).Result; if (issue is null) { return null; } return new WorkItemLink { Id = workItemId, Description = GetReleaseNote(issue, releaseNotePrefix), LinkUrl = baseUrl + "/browse/" + workItemId }; }) .Where(i => i != null) .ToArray()); }
public OctopusPackageMetadataMappedResource Push(string packageId, string version, OctopusPackageMetadata octopusMetadata) { if (string.IsNullOrWhiteSpace(packageId)) { throw new ArgumentException("A package Id must be supplied", nameof(packageId)); } if (string.IsNullOrWhiteSpace(version)) { throw new ArgumentException("A version must be supplied", nameof(version)); } var resource = new OctopusPackageMetadataVersionResource { PackageId = packageId, Version = version, OctopusPackageMetadata = octopusMetadata, }; var link = repository.Link("PackageMetadata"); return(repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource)); }
public async Task <OctopusPackageMetadataMappedResource> Push(string packageId, string version, OctopusPackageMetadata octopusMetadata, OverwriteMode overwriteMode) { if (string.IsNullOrWhiteSpace(packageId)) { throw new ArgumentException("A package Id must be supplied", nameof(packageId)); } if (string.IsNullOrWhiteSpace(version)) { throw new ArgumentException("A version must be supplied", nameof(version)); } var resource = new OctopusPackageMetadataVersionResource { PackageId = packageId, Version = version, OctopusPackageMetadata = octopusMetadata }; if (await repository.HasLink("BuildInformation")) { Logger.Warn("Connected to an Octopus server that supports the BuildInformation API. It is recommended you move to using the BuildInformationRepository as the PackageMetadataRepository is deprecated."); } if (!(await repository.HasLink("PackageMetadata"))) { throw new OperationNotSupportedByOctopusServerException( OctopusPackageMetadata.PackageMetadataRequiresOctopusVersionMessage, OctopusPackageMetadata.PackageMetadataRequiresOctopusVersion); } var link = await repository.Link("PackageMetadata"); // if the link contains overwriteMode then we're connected to a new server, if not use the old `replace` parameter if (link.Contains(OverwriteModeLink.Link)) { return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { overwriteMode = overwriteMode })); } else { return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { replace = overwriteMode.ConvertToLegacyReplaceFlag(Logger) })); } }
public Task <OctopusPackageMetadataMappedResource> Push(string packageId, string version, OctopusPackageMetadata octopusMetadata, bool replaceExisting) { return(Push(packageId, version, octopusMetadata, replaceExisting ? OverwriteMode.OverwriteExisting : OverwriteMode.FailIfExists)); }
public OctopusPackageMetadataMappedResource Push(string packageId, string version, OctopusPackageMetadata octopusMetadata) { return(Push(packageId, version, octopusMetadata, OverwriteMode.FailIfExists)); }
public async Task <OctopusPackageMetadataMappedResource> Push(string packageId, string version, OctopusPackageMetadata octopusMetadata, bool replaceExisting) { if (string.IsNullOrWhiteSpace(packageId)) { throw new ArgumentException("A package Id must be supplied", nameof(packageId)); } if (string.IsNullOrWhiteSpace(version)) { throw new ArgumentException("A version must be supplied", nameof(version)); } var resource = new OctopusPackageMetadataVersionResource { PackageId = packageId, Version = version, OctopusPackageMetadata = octopusMetadata }; var link = await repository.Link("PackageMetadata"); return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { replace = replaceExisting })); }
public string[] ParseWorkItemIds(OctopusPackageMetadata packageMetadata) { return(packageMetadata.Commits.SelectMany(c => WorkItemIds(c.Comment)) .Where(workItemId => !string.IsNullOrWhiteSpace(workItemId)) .ToArray()); }
public async Task <OctopusPackageMetadataMappedResource> Push(string packageId, string version, OctopusPackageMetadata octopusMetadata, OverwriteMode overwriteMode) { if (string.IsNullOrWhiteSpace(packageId)) { throw new ArgumentException("A package Id must be supplied", nameof(packageId)); } if (string.IsNullOrWhiteSpace(version)) { throw new ArgumentException("A version must be supplied", nameof(version)); } var resource = new OctopusPackageMetadataVersionResource { PackageId = packageId, Version = version, OctopusPackageMetadata = octopusMetadata }; var link = await repository.Link("PackageMetadata"); // if the link contains overwriteMode then we're connected to a new server, if not use the old `replace` parameter if (link.Contains(OverwriteModeLink.Link)) { return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { overwriteMode = overwriteMode })); } else { return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { replace = overwriteMode == OverwriteMode.OverwriteExisting })); } }