public Task Execute(RunningDeployment context) { substituteInFiles.SubstituteBasedSettingsInSuppliedVariables(context.CurrentDirectory); return(this.CompletedTask()); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); Guard.NotNullOrWhiteSpace(pathToPackage, "No package file was specified. Please pass --package YourPackage.nupkg"); if (!File.Exists(pathToPackage)) { throw new CommandException("Could not find package file: " + pathToPackage); } Log.Info("Deploying package: " + pathToPackage); var featureClasses = new List <IFeature>(); var replacer = new ConfigurationVariablesReplacer(variables.GetFlag(SpecialVariables.Package.IgnoreVariableReplacementErrors)); var generator = new JsonConfigurationVariableReplacer(); var configurationTransformer = ConfigurationTransformer.FromVariables(variables); var transformFileLocator = new TransformFileLocator(fileSystem); var embeddedResources = new AssemblyEmbeddedResources(); #if IIS_SUPPORT var iis = new InternetInformationServer(); featureClasses.AddRange(new IFeature[] { new IisWebSiteBeforeDeployFeature(), new IisWebSiteAfterPostDeployFeature() }); #endif if (!CalamariEnvironment.IsRunningOnWindows) { featureClasses.Add(new NginxFeature(NginxServer.AutoDetect(), fileSystem)); } var semaphore = SemaphoreFactory.Get(); var journal = new DeploymentJournal(fileSystem, semaphore, variables); var conventions = new List <IConvention> { new AlreadyInstalledConvention(log, journal), new DelegateInstallConvention(d => extractPackage.ExtractToApplicationDirectory(pathToPackage)), new FeatureConvention(DeploymentStages.BeforePreDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new ConfiguredScriptConvention(DeploymentStages.PreDeploy, fileSystem, scriptEngine, commandLineRunner), new PackagedScriptConvention(log, DeploymentStages.PreDeploy, fileSystem, scriptEngine, commandLineRunner), new FeatureConvention(DeploymentStages.AfterPreDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new DelegateInstallConvention(d => substituteInFiles.SubstituteBasedSettingsInSuppliedVariables(d)), new ConfigurationTransformsConvention(fileSystem, configurationTransformer, transformFileLocator), new ConfigurationVariablesConvention(fileSystem, replacer), new JsonConfigurationVariablesConvention(generator, fileSystem), new CopyPackageToCustomInstallationDirectoryConvention(fileSystem), new FeatureConvention(DeploymentStages.BeforeDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new PackagedScriptConvention(log, DeploymentStages.Deploy, fileSystem, scriptEngine, commandLineRunner), new ConfiguredScriptConvention(DeploymentStages.Deploy, fileSystem, scriptEngine, commandLineRunner), new FeatureConvention(DeploymentStages.AfterDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), #if IIS_SUPPORT new LegacyIisWebSiteConvention(fileSystem, iis), #endif new FeatureConvention(DeploymentStages.BeforePostDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new PackagedScriptConvention(log, DeploymentStages.PostDeploy, fileSystem, scriptEngine, commandLineRunner), new ConfiguredScriptConvention(DeploymentStages.PostDeploy, fileSystem, scriptEngine, commandLineRunner), new FeatureConvention(DeploymentStages.AfterPostDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new RollbackScriptConvention(log, DeploymentStages.DeployFailed, fileSystem, scriptEngine, commandLineRunner), new FeatureRollbackConvention(DeploymentStages.DeployFailed, fileSystem, scriptEngine, commandLineRunner, embeddedResources) }; var deployment = new RunningDeployment(pathToPackage, variables); var conventionRunner = new ConventionProcessor(deployment, conventions); try { conventionRunner.RunConventions(); if (!deployment.SkipJournal) { journal.AddJournalEntry(new JournalEntry(deployment, true)); } } catch (Exception) { if (!deployment.SkipJournal) { journal.AddJournalEntry(new JournalEntry(deployment, false)); } throw; } return(0); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); Guard.NotNullOrWhiteSpace(archiveFile, "No archive file was specified. Please pass --archive YourPackage.jar"); JavaRuntime.VerifyExists(); if (!File.Exists(archiveFile)) { throw new CommandException("Could not find archive file: " + archiveFile); } Log.Info("Deploying: " + archiveFile); var semaphore = SemaphoreFactory.Get(); var journal = new DeploymentJournal(fileSystem, semaphore, variables); var jsonReplacer = new JsonConfigurationVariableReplacer(); var jarTools = new JarTool(commandLineRunner, log, variables); var packageExtractor = new JarPackageExtractor(jarTools); var embeddedResources = new AssemblyEmbeddedResources(); var javaRunner = new JavaRunner(commandLineRunner, variables); var featureClasses = new List <IFeature> { new TomcatFeature(javaRunner), new WildflyFeature(javaRunner) }; var deployExploded = variables.GetFlag(SpecialVariables.Action.Java.DeployExploded); var conventions = new List <IConvention> { new AlreadyInstalledConvention(log, journal), // If we are deploying the package exploded then extract directly to the application directory. // Else, if we are going to re-pack, then we extract initially to a temporary directory deployExploded ? (IInstallConvention) new DelegateInstallConvention(d => extractPackage.ExtractToApplicationDirectory(archiveFile, packageExtractor)) : new DelegateInstallConvention(d => extractPackage.ExtractToStagingDirectory(archiveFile, packageExtractor)), new FeatureConvention(DeploymentStages.BeforePreDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new ConfiguredScriptConvention(DeploymentStages.PreDeploy, fileSystem, scriptEngine, commandLineRunner), new PackagedScriptConvention(log, DeploymentStages.PreDeploy, fileSystem, scriptEngine, commandLineRunner), new FeatureConvention(DeploymentStages.AfterPreDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new DelegateInstallConvention(d => substituteInFiles.SubstituteBasedSettingsInSuppliedVariables(d)), new JsonConfigurationVariablesConvention(jsonReplacer, fileSystem), new RePackArchiveConvention(log, fileSystem, jarTools), new CopyPackageToCustomInstallationDirectoryConvention(fileSystem), new FeatureConvention(DeploymentStages.BeforeDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new PackagedScriptConvention(log, DeploymentStages.Deploy, fileSystem, scriptEngine, commandLineRunner), new ConfiguredScriptConvention(DeploymentStages.Deploy, fileSystem, scriptEngine, commandLineRunner), new FeatureConvention(DeploymentStages.AfterDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new FeatureConvention(DeploymentStages.BeforePostDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new PackagedScriptConvention(log, DeploymentStages.PostDeploy, fileSystem, scriptEngine, commandLineRunner), new ConfiguredScriptConvention(DeploymentStages.PostDeploy, fileSystem, scriptEngine, commandLineRunner), new FeatureConvention(DeploymentStages.AfterPostDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources), new RollbackScriptConvention(log, DeploymentStages.DeployFailed, fileSystem, scriptEngine, commandLineRunner), new FeatureRollbackConvention(DeploymentStages.DeployFailed, fileSystem, scriptEngine, commandLineRunner, embeddedResources) }; var deployment = new RunningDeployment(archiveFile, variables); var conventionRunner = new ConventionProcessor(deployment, conventions); try { conventionRunner.RunConventions(); if (!deployment.SkipJournal) { journal.AddJournalEntry(new JournalEntry(deployment, true)); } } catch (Exception) { if (!deployment.SkipJournal) { journal.AddJournalEntry(new JournalEntry(deployment, false)); } throw; } return(0); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); if (!ServiceFabricHelper.IsServiceFabricSdkKeyInRegistry()) { throw new CommandException("Could not find the Azure Service Fabric SDK on this server. This SDK is required before running Service Fabric commands."); } Guard.NotNullOrWhiteSpace(pathToPackage, "No package file was specified. Please pass --package YourPackage.nupkg"); if (!File.Exists(pathToPackage)) { throw new CommandException("Could not find package file: " + pathToPackage); } Log.Info("Deploying package: " + pathToPackage); var fileSystem = new WindowsPhysicalFileSystem(); var embeddedResources = new AssemblyEmbeddedResources(); var replacer = new ConfigurationVariablesReplacer(variables.GetFlag(SpecialVariables.Package.IgnoreVariableReplacementErrors)); var jsonReplacer = new JsonConfigurationVariableReplacer(); var configurationTransformer = ConfigurationTransformer.FromVariables(variables); var transformFileLocator = new TransformFileLocator(fileSystem); var conventions = new List <IConvention> { new DelegateInstallConvention(d => extractPackage.ExtractToStagingDirectory(pathToPackage)), // PreDeploy stage new ConfiguredScriptConvention(DeploymentStages.PreDeploy, fileSystem, scriptEngine, commandLineRunner), new PackagedScriptConvention(log, DeploymentStages.PreDeploy, fileSystem, scriptEngine, commandLineRunner), // Standard variable and transform replacements new DelegateInstallConvention(d => substituteInFiles.SubstituteBasedSettingsInSuppliedVariables(d)), new ConfigurationTransformsConvention(fileSystem, configurationTransformer, transformFileLocator), new ConfigurationVariablesConvention(fileSystem, replacer), new JsonConfigurationVariablesConvention(jsonReplacer, fileSystem), // Deploy stage new PackagedScriptConvention(log, DeploymentStages.Deploy, fileSystem, scriptEngine, commandLineRunner), new ConfiguredScriptConvention(DeploymentStages.Deploy, fileSystem, scriptEngine, commandLineRunner), // Variable replacement new SubstituteVariablesInAzureServiceFabricPackageConvention(fileSystem, fileSubstituter), // Main Service Fabric deployment script execution new EnsureCertificateInstalledInStoreConvention(certificateStore, SpecialVariables.Action.ServiceFabric.ClientCertVariable, SpecialVariables.Action.ServiceFabric.CertificateStoreLocation, SpecialVariables.Action.ServiceFabric.CertificateStoreName), new DeployAzureServiceFabricAppConvention(log, fileSystem, embeddedResources, scriptEngine, commandLineRunner), // PostDeploy stage new PackagedScriptConvention(log, DeploymentStages.PostDeploy, fileSystem, scriptEngine, commandLineRunner), new ConfiguredScriptConvention(DeploymentStages.PostDeploy, fileSystem, scriptEngine, commandLineRunner), }; var deployment = new RunningDeployment(pathToPackage, variables); var conventionRunner = new ConventionProcessor(deployment, conventions); conventionRunner.RunConventions(); return(0); }