Loop a step with variables

(Asimsuvedi) #1

Hi,

I have a project where I have setup up steps to deploy change scripts to multiple databases. The scripts are exactly same, the step is exactly same except the databases are different. So we have 74 steps, each exactly same except the database name for 74 databases. I was trying to figure out if we could store these 74 database names somewhere and have one step which can loop based on the 74 database names, more like a for loop

(Ziaul Islam) #3

Hi Asim,

Welcome to Octopus!

I recommend you store the database connection strings using a variable then reference the variable.

I’ll attach a link for you which will give you a guide on how to do use variables:

So an example of this would be:

The second option is you could scope the connection string to a target role.

By doing this, you scope your connection string with a target and associate that with the deployment.

Example of Target roles:
-DbConnection1
-DbConnection2
-DbConnection3

I hope this helps you if you need any further advice, please don’t hesitate to contact me.

Kind regards,
Ziaul