Deploy a file depending on environment

I use a load testing tool that will only run against a website that has a specific file in the root. I would like this file to be deployed to my dev and test environments but not my production environment.

Is there a way to do this?

Hi Steven,

Thanks for getting in touch! It looks like you are after our scoping feature! In Octopus you are able to scope a step to a certain environment. See Screenshot1.jpg.
In my screenshot, I have opened the step which I want to restrict to Development and Testing environments and entered them into the run conditions. Now during deployment, this step will only run if it’s running on a those environments.

I hope that helps. :slight_smile: Let me know if you have any further questions.

Best regards,

Hi Daniel,
I’m not sure this helps me, unless I missing something.

To expand on my example.

I have a project that I use to deploy to my test environment then I promote to my live environment. The package is built in TeamCity once, for both these environments. When promoting to live I want a file to be excluded from the deployment, is this possible?


Hi Steven,

Thanks for getting back! It looks like I misinterpreted what you were after here. :slight_smile:
From what you have explained, you need to deploy a file from a single package to two environments, Dev and Test, but NOT deploy to your live production server.

You have a couple of options available to you here. First, you can create a script step at the end of your deployment, scoped to your production environment. The script could be used to delete the file and if it is scoped to only production, it will only run on that server. The other option is to add some PowerShell in your post-deploy script to remove the file if it is deployed to production.

Below are some links that may help you in doing this. :slight_smile:

The system variables link has different variables that can be called in PowerhSell that could help.

E.g. Octopus.Environment.Id - The ID of the environment

Let me know if this helps, or if you have any further questions here.

Best regards,