How to programmatically set the website location

Hi,

When deploying an IIS website using a package, I would like to be able to set the Custom install directory path by checking against IIS the physical path of the website(using powershell). Hence in the variable I only need to set the name of the website, using that variable I can stop the website, deploy the website and check the success of the deployment. I am trying to create a step templates and would like to reuse the deploy package step for various website deployments and since we have multiple servers, I would like to not have to know where each website is located on each server. What’s the best way of doing this?

We are on version 3.2.23

Thanks,
Milan

This worked:

In my ‘Deploy package’ step template, I added the following pre-deployment script:

$webPath = (Get-Website -Name “$Endpoint”).PhysicalPath
Set-OctopusVariable -name ‘Octopus.Action.Package.CustomInstallationDirectory’ -value $webPath

note:
-set #{Endpoint} as a variable in the project, which is the name of the website
-enable custom install directory in the step template for the variable to be present

This means that I only need to specify the name of the package and the name of the website.

Hi Milan,

Thanks for getting in touch. I’m glad you were able to figure out a good way to achieve your goal!

Please don’t hesitate to reach out if we can help you with anything else.

Happy Deployments!
Mike