Exemplo n.º 1
0
        internal override void Execute(SkytapClient client, SkytapConfiguration configuration)
        {
            if (string.IsNullOrWhiteSpace(this.NewConfigurationName))
            {
                this.LogInformation("Creating environment from {1} environment...", configuration.Name);
            }
            else
            {
                this.LogInformation("Creating {0} environment from {1} template...", this.NewConfigurationName, configuration.Name);
            }

            string configurationId;

            try
            {
                configurationId = client.CopyConfiguration(configuration.Id);
            }
            catch (WebException ex)
            {
                this.LogError("The environment could not be copied: " + ex.Message);
                return;
            }

            this.LogDebug("Environment copied (ID={0})", configurationId);

            if (!string.IsNullOrWhiteSpace(this.NewConfigurationName))
            {
                this.LogDebug("Setting environment name to {0}...", this.NewConfigurationName);
                client.RenameConfiguration(configurationId, this.NewConfigurationName);
                this.LogDebug("Environment renamed.");
            }

            if (this.ExportVariables)
            {
                this.SetSkytapVariableValue("EnvironmentId", configurationId);
            }

            this.LogInformation("Environment copied.");
        }