Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Octopus Deploy to Multiple Database Instances

Alex Cason Jun 07, 2013 07:44PM AEST

We use Octopus Deploy to manage our internal releases. In one of our environments we have multiple instances of our database, each containing different data, which need to be kept in sync when a release is published to this environment.

It's working fine for a single database on a single server. Variables exist for DatabaseServer and DatabaseName and the scripts are deployed to this database without any problems.

Is it possible to sepecify multiple instances in the DatabaseServer and DatabaseName variables so that each instance would be updated when a release was deployed? I've looked into how sqlcmd would actually handle this and I haven't found any concrete information.

Thanks for your help.

Up 0 rated Down
Daniel Nolan Jun 07, 2013 09:07PM AEST ReadyRoll Agent

Hi Alex,

Thanks for getting in touch. Unfortunately it is currently not possible to specify multiple DatabaseServer / DatabaseName instances in the Octopus variables.

A simple enhancement to ReadyRoll we could do is to assume “localhost” for the database instance, but that would only work if the former case is true (you would just need a Tentacle on each database server).

If it is the latter, then we may need to get a bit more creative. Possibly a comma-delimited string of database names would be needed, as I don’t believe Octopus supports array variables.

Best Regards,

Daniel

Up 0 rated Down
Matt Tyler Feb 13, 2015 12:12PM AEDT
I came up with a workaround using powerscript.

In Visual Studio I added the following Post Build Event:
powershell.exe -file $(ProjectDir)SetDatabaseVariables.ps1

Then, in the project directory, I created SetDatabaseVariables.ps1:
$file = "deploy.ps1"
$find = "# Variable validation"
$replace = "# Variable validation`r`n`$DatabaseServer = `$MyOtherDatabaseServer`r`n`$DatabaseName = `$MyOtherDatabaseName"
$content = Get-Content $file -Raw
#write replaced content back to the file
$content -replace $find,$replace | Out-File $file

(There is probably a better way to add 2 lines to a file rather than using find and replace but I'm new to powerscript)

This sets the DatabaseServer and DatabaseName variables to different Octopus variables before the file is added to the nuget package. It works fine with Team City.

I showed my colleague this who then came up with a much better and simpler solution - use roles. So you can have multiple DatabaseServer and DatabaseName variables as long as they use different roles. Then just set the machine role in the step for each database your deploying.

Matt

This question has received the maximum number of answers.

readyroll.support@red-gate.com
http://assets3.desk.com/
false
readyrollsql
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete