-
Notifications
You must be signed in to change notification settings - Fork 4
Octopus Deploy
Eivind Gussiås Løkseth edited this page Jun 18, 2020
·
1 revision
- Download this module and import into octopus deploy as shown in http://docs.octopusdeploy.com/display/OD/Script+Modules
- Create a deployment process that contains the steps shown in this screen shot:
Each substep in the deployment step contains PowerShell snippets
##Octopus environment variables required for this deployment,
##For non-clustered BizTalk server environments set this to true always
$IsFirstBiztalkServer = $OctopusParameters['Octopus.Machine.Roles'] -contains "biztalk-primary"
$IsFirstBiztalkServer = $True #for some reason the test above doesn't work
$appPoolIdentity = $OctopusParameters['AppPoolIdentity']
$appPoolPassword = $OctopusParameters['AppPoolPassword']
$undeployDependentApps = $OctopusParameters['Octopus.Environment.Name'].StartsWith("DEV")
##initialise variables
$backupDir = Join-Path "C:\BizTalkApps" "Backup"
$biztalkAppName = $OctopusParameters["BizTalkApplicationName"]
$btdfProductName = $biztalkAppName
##If you have more options in your BTDF installwizard.xml, just add them as name value pairs as shown here.
##PS. The /p: is mandatory :
##Make sure the names or values with spaces are enclosed within double quotes.
##Double quotes in PowerShell strings can be escaped using "" or `"
##In this example, see the value of /p:ENV_Settings is escaped with ""
Write-Verbose "App pool identity: $appPoolIdentity"
$undeployOptions = @{"/p:VDIR_USERNAME"="$($appPoolIdentity)";
"/p:VDIR_USERPASS"="$($appPoolPassword)";
"/p:BTSACCOUNT"="biztalk";
}
New-Item $backupDir -ItemType Container -Force
#unpublish using the powershell module.
unpublish-btdfbiztalkapplication -verbose -btdfProductName $btdfProductName -biztalkApplicationName $biztalkAppName -importIntoBiztalkMgmtDb $IsFirstBiztalkServer -backupdir $backupDir -undeployOptions $undeployOptions -undeployDependentApps $undeployDependentApps
##To see more options available to customise you deployment including custom undeploy options, set msbuild or BTS task paths use get-help
#Get-Help Unpublish-BTDFBiztalkApplication -Detailed
##To troubleshoot and increase log level use the -Verbose switch
#Unpublish-BTDFBiztalkApplication -verbose
##Get MSI from nuget package.
$installDir = $OctopusParameters['Octopus.Action[Deploy package].Output.Package.InstallationDirectoryPath']
Set-OctopusVariable -name "InstallDir" -value $installDir
##This assumes you have created a nuget package with the msi and the msi is under content dir when the nuget package is unpacked
$Msi = Get-Item "$(Join-Path $installDir $OctopusParameters["BizTalkApplicationName"])*.msi"
##initialise variables
$installOptions = $NULL
install-btdfBiztalkApp -Verbose $Msi -installDir $installdir -installOptions $installOptions
##Get MSI from nuget package.
$installDir = $OctopusParameters['Octopus.Action[Install MSI].Output.InstallDir']
Write-Verbose "installDir = $installDir"
#Run EnvironmentSetttingsExporter.exe to genereate xml file for environment
#to replace its values with matching Octopus variables
$settingsFolder = Export-EnvironmentSettings $installDir
Set-OctopusVariable -name "SettingsFolder" -value $settingsFolder
#Delte SettingsFileGenerator.xml so BTDF doesn't overwrite our exported settings on deploy
$sourceSettingsFile = Join-Path $settingsFolder "SettingsFileGenerator.xml"
Remove-Item -Path $sourceSettingsFile
# Call Substitute-XmlSettingsFileValues in script module
$settingsFolder = $OctopusParameters["Octopus.Action[Export environment settings].Output.SettingsFolder"]
$settingsFilePath = Join-Path $settingsFolder "Octopus_settings.xml"
Substitute-XmlSettingsFileValues $settingsFilePath $OctopusParameters
##Octopus environment variables required for this deployment,
##For non-clustered BizTalk server environments set this to true always
#$IsFirstBiztalkServer = $true
$MachineRoles = $OctopusParameters['Octopus.Machine.Roles']
foreach($r in $MachineRoles)
{
Write-Host "Role: $r"
}
$IsFirstBiztalkServer = $OctopusParameters['Octopus.Machine.Roles'] -contains "biztalk-primary"
$IsFirstBiztalkServer = $True #for some reason the test above doesn't work
Write-Verbose "IsFirstBiztalkServer = $IsFirstBiztalkServer"
$appPoolIdentity = $OctopusParameters['AppPoolIdentity']
$appPoolPassword = $OctopusParameters['AppPoolPassword']
##initialise variables
$btdfProductName = $OctopusParameters["BizTalkApplicationName"]
##If you have more options in your BTDF installwizard.xml, just add them as name value pairs as shown here.
##PS. The /p: is mandatory :
##Make sure the names or values with spaces are enclosed within double quotes.
##Double quotes in PowerShell strings can be escaped using "" or `"
##In this example, see the value of /p:ENV_Settings is escaped with ""
$octpousEnvironmentSettingsFile = "Octopus_settings.xml"
$envSettingsPath = $OctopusParameters["Octopus.Action[Export environment settings].Output.SettingsFolder"]
$octpousEnvironmentSettingsPath = (Join-Path $envSettingsPath $octpousEnvironmentSettingsFile)
Write-Verbose "Settings path: $octpousEnvironmentSettingsPath"
Write-Verbose "App pool identity: $appPoolIdentity"
$deployOptions = @{"/p:VDIR_USERNAME"="$($appPoolIdentity)";
"/p:VDIR_USERPASS"="$($appPoolPassword)";
"/p:BTSACCOUNT"="biztalk";
"/p:SettingsFilePath"="""$($octpousEnvironmentSettingsPath)""";
}
##Deploy using the powershell module.
Deploy-BTDFBiztalkApp -verbose -btdfProductName $btdfProductName -importIntoBiztalkMgmtDb $IsFirstBiztalkServer -deployOptions $deployOptions
##To see more options available to customise you deployment including custom undeploy options, set msbuild or BTS task paths use get-help
#Get-Help Deploy-BTDFBiztalkApp -Detailed
##To troubleshoot and increase log level use the -Verbose switch
#Deploy-BTDFBiztalkApp -verbose