Options

Powershell and deployment sequencing...

edited July 4, 2013 7:51AM in Deployment Manager
The documentation says that the 4 preset powershell scripts will be run at deployment. It is not clear where those scripts are when they run. For example, my PreDeploy.ps1 script would like to use app_offline.htm on the target website to shut off access, and then copy the predeployment contents of the website to "\Backup Websites" directory.

Is the PreDeploy.ps1 script in some temp place on the target system when it gets run? Is it placed in the target physical location of the website before it is run? That would make it hard to copy the previous website contents because they'd be gone!

There are other similar tasks for predeployment. We need to backup the previous installation exe for third party software saved in a known directory on the target machine.

Comments

  • Options
    The deployment sequence is as follows:
    1. The contents of the package is extracted to a sub-directory of the path you chose during installation of the Agent. The base path defaults to "C:\ProgramData\Red Gate\DeploymentAgent\Applications", and the subdirectory used is <environment_name>\<package_name>\<package_version>\.
    2. PreDeploy.ps1 is executed in that directory.
    3. Any relevant XML config transforms are executed
    4. Variable substitutions are performed on .config files.
    5. If the RedGatePackageDirectoryPath variable is set, the extracted (and possibly modified by previous steps) contents in that directory are copied to the directory set in that variable. The working directory for all subsequent steps is changed to the new location. Note that if RedGatePackageDirectoryPath is not set, the initial directory in the Deployment Agent's data storage location continues to be used.
    6. Database deployment (if applicable) is carried out
    7. The Deploy.ps1 script(s) is executed
    8. If a web.config file is present in the directory, IIS is updated to serve the website from the new physical location.
    9. The package file itself (the .nupkg file) is deleted from the application location
    10. The PostDeploy.ps1 script(s) is executed

    Hope that helps,
    Mike
    Development Lead
    Redgate Software
  • Options
    We would love to be able to create a reusable set of powershell cmd-lets that all applications may use on an agent. Things like backup database, put app off line, turn off app pool, turn on app pool...

    What is the way to go here? Do you setup a powershell library directory on each agent and update that first with a prerequisites deployment?
  • Options
    We think the best way to solve this is to create a nuget package of your Powershell libraries.

    You can then deploy this package as the first step in your deployments, so that each subsequent step will be able to use the extracted scripts.

    By specifying RedGatePackageDirectoryPath to be the location you want to store the scripts, each deployment will override previous ones (since they will be in the same directory), and it will be easy to work out where the scripts have been extracted.

    This has the advantage that Nuget will deal with versioning for you, and you don't need to worry about keeping each agent up to date, since it will be updated at deployment time.
    David Conlin
    Software Developer
    Deployment Manager
Sign In or Register to comment.