SQL - Execute Script File

Hi there,

I have defined a process that consists of 2 steps:

  1. Deploy an IIS WebSite
  2. Execute a script file

The first step in the process executes without any issues. I am able to upload a nuget package to Octopus Server’s built-in package repository and deploy this to my IIS Web Site.

For the second step in the process, where I am asked to specify a script file to run, I am unable to upload a sql file either using the built-in package repository or using a external package repository since Octopus will not allow me to upload a .sql file type.

What is the best way of specifying the SQL Script File to be run?

Should I package it along with my nuget package and then specify the script source to ‘Script file inside a package’ or is it possible to upload a SQL file to a repository (external or built-in) and specify that file as the SQL script file to execute?

Is there a best practice for this?

Thanks,

Sean

Hi Sean,

Thanks for getting in touch! While you won’t be able to deploy a SQL file directly (you can refer to the package types we support in our documentation), the best way to execute a SQL script file is to package it along with your NuGet package.

The SQL Script File section in the step configuration expects a path to the script file. You can get the path that your package installs to by using an output variable, which would be followed by your script file name. In your SQL Script File section, the value should look like the following (input your script file name):
#{Octopus.Action[Deploy Package].Output.Package.InstallationDirectoryPath}\ScriptFileName.sql

I hope that helps! Let me know how you go and if you have any further questions.

Best regards,

Kenny