/// <summary>
        /// Uploads an AppVeyor artifact.
        /// </summary>
        /// <param name="path">The file path of the artifact to upload.</param>
        /// <param name="settingsAction">The settings to apply when uploading an artifact</param>
        public void UploadArtifact(FilePath path, Action <AppVeyorUploadArtifactsSettings> settingsAction)
        {
            if (settingsAction == null)
            {
                throw new ArgumentNullException(nameof(settingsAction));
            }

            var settings = new AppVeyorUploadArtifactsSettings();

            settingsAction(settings);
            UploadArtifact(path, settings);
        }
Esempio n. 2
0
        /// <summary>
        /// Uploads an AppVeyor artifact.
        /// </summary>
        /// <param name="path">The file path of the artifact to upload.</param>
        /// <param name="settings">The settings to apply when uploading an artifact</param>
        public void UploadArtifact(FilePath path, AppVeyorUploadArtifactsSettings settings)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (!IsRunningOnAppVeyor)
            {
                throw new CakeException("The current build is not running on AppVeyor.");
            }

            // Make path absolute.
            path = path.IsRelative ? path.MakeAbsolute(_environment) : path;

            // Build the arguments.
            var arguments = new ProcessArgumentBuilder();

            arguments.Append("PushArtifact");
            arguments.Append("-Path");
            arguments.AppendQuoted(path.FullPath);
            arguments.Append("-FileName");
            arguments.AppendQuoted(path.GetFilename().FullPath);
            arguments.Append("-ArtifactType");
            arguments.AppendQuoted(settings.ArtifactType.ToString());
            if (!string.IsNullOrEmpty(settings.DeploymentName))
            {
                if (settings.DeploymentName.Contains(" "))
                {
                    throw new CakeException("The deployment name can not contain spaces");
                }
                arguments.Append("-DeploymentName");
                arguments.AppendQuoted(settings.DeploymentName);
            }

            // Start the process.
            _processRunner.Start("appveyor", new ProcessSettings {
                Arguments = arguments
            });
        }