Execute SQL Script depending on environment level

Hi,

Apologies if this has already been asked, I did search the forum but couldn’t find anything directly related.

I’m fairly new to Octopus Deploy so I am still not completely familiar with it’s capabilities.

Within our Octopus Deploy process we have a step to deploy database which runs a DbScripts nuget package.

I would like to know if it is at all possible for Octopus Deploy to run certain scripts based on what environment level it is deploying to.

For instance, we have a script to insert some configuration values into a sql table. These values need to be different based on whether they are in Development, QA, & Production.

Is it possible for Octopus Deploy to recognize what environment it is deploying to and then do some kind of variable substitution?

Thanks

Hi Gary,

Thanks for getting in touch!

Absolutely, there should be no problem doing this. The basics of this would be to amend your files to include variable names in place of these values e.g.

    <authentication mode="Forms">
      <forms loginUrl="#{LoginURL}" timeout="2880" />
    </authentication>

Then you would add that value to your Project Variables and scope to different environments e.g.

Finally, you would enable the Substitute Variables in Files option within the process step and configure as needed.

There are full details of the entire process available here: https://octopus.com/docs/deployment-process/configuration-features/substitute-variables-in-files

If you run into any issues, please let me know.

Regards,
Paul

1 Like

Thanks for your response Paul! I will check out the full details and confirm back if I’ve managed to get it working or not

1 Like