public async Task Request()
        {
            if (string.IsNullOrEmpty(File))
            {
                throw new CommandException("Please specify the build information file.");
            }
            if (PackageIds.None())
            {
                throw new CommandException("Please specify at least one package id.");
            }
            if (string.IsNullOrEmpty(Version))
            {
                throw new CommandException("Please specify the package version.");
            }

            if (!FileSystem.FileExists(File))
            {
                throw new CommandException($"Build information file '{File}' does not exist");
            }

            var fileContent = FileSystem.ReadAllText(File);

            var buildInformation = JsonConvert.DeserializeObject <OctopusBuildInformation>(fileContent);

            foreach (var packageId in PackageIds)
            {
                commandOutputProvider.Debug("Pushing build information for package {PackageId} version {Version}...", packageId, Version);
                resultResource = await Repository.BuildInformationRepository.Push(packageId, Version, buildInformation, OverwriteMode);

                pushedBuildInformation.Add(resultResource);
            }
        }
Ejemplo n.º 2
0
        public async Task Request()
        {
            if (string.IsNullOrEmpty(File))
            {
                throw new CommandException("Please specify the build information file.");
            }
            if (PackageIds.None())
            {
                throw new CommandException("Please specify at least one package id.");
            }
            if (string.IsNullOrEmpty(Version))
            {
                throw new CommandException("Please specify the package version.");
            }

            if (!FileSystem.FileExists(File))
            {
                throw new CommandException($"Build information file '{File}' does not exist");
            }

            var fileContent = FileSystem.ReadAllText(File);

            var rootDocument = await Repository.LoadRootDocument();

            if (rootDocument.HasLink("BuildInformation"))
            {
                var buildInformation = JsonConvert.DeserializeObject <OctopusBuildInformation>(fileContent);

                foreach (var packageId in PackageIds)
                {
                    commandOutputProvider.Debug("Pushing build information for package {PackageId} version {Version}...", packageId, Version);
                    resultResource = await Repository.BuildInformationRepository.Push(packageId, Version, buildInformation, OverwriteMode);

                    pushedBuildInformation.Add(resultResource);
                }
            }
            else
            {
                commandOutputProvider.Warning("Detected Octopus server version doesn't support the Build Information API.");

                var metadata = JsonConvert.DeserializeObject <OctopusPackageMetadata>(fileContent);
                // old server won't parse without the CommentParser being set, default it to Jira
                metadata.CommentParser = "Jira";

                foreach (var packageId in PackageIds)
                {
                    commandOutputProvider.Debug("Pushing build information as legacy package metadata for package {PackageId} version {Version}...", packageId, Version);
                    var result = await Repository.PackageMetadataRepository.Push(packageId, Version, metadata, OverwriteMode);
                }
            }
        }
 public void Delete(OctopusPackageVersionBuildInformationMappedResource buildInformation)
 {
     repository.Client.Delete(repository.Link("BuildInformation"), new { id = buildInformation.Id });
 }
Ejemplo n.º 4
0
 public async Task Delete(OctopusPackageVersionBuildInformationMappedResource buildInformation)
 {
     await repository.Client.Delete(await repository.Link("BuildInformation").ConfigureAwait(false), new { id = buildInformation.Id }).ConfigureAwait(false);
 }