Zip Up and Move An Offline Deployment Package

I need to find an automated way to upload an offline deployment package to an FTP server. This is to support deployments in a gapped environment.

The use case is this:

1 - Offline Deployment Package (ODP) is created in local server folder.
2 - ODP is zipped up in the local folder and then FTPed to a remote folder for later execution.

The ODP will be manually run later from the remote server to deploy the application. The remote location is gapped and only makes an FTP server available for uploads.

Hi @wg,

Thanks for reaching out. Have you tried implementing this logic in a PowerShell script step? I believe you should be able to accomplish this via that method. Please let me know if that works for you or if you need further assistance.


The issue is, how do we execute the script? Using powershell would be fine, but this is NOT part of the deployment process. This is after OD creates the Offline Deployment Package, not when the deployment package is run. At the end of the ODP creation, we need to have some hooks that can execute a script.

If you know a way to do this using a “step”, please educate me.

Thanks in advance.

The way we do it today is to manually run a script after the offline package drop is created. What we need is some way for the deployment target worker to allow us to run a script when it finishes outputting all of the files to the drop location. Or something comparable.

hi @wg,

I think the way to go about this will be to have two separate projects. You will need to configure your ODP target to create an Artifact rather than a Drop Folder to use the logic below.

The first project(Project A) will create the offline package artifact that we will later FTP.

The second project(Project B) will then be a meta project, which will be the one you will run. The steps will be:
Step 1. Deploy a release in Project A.
Step 2. Using API calls, gather the artifact from the release from Project A, then run your FTP commands.

Here is some code to help you get Step 2 accomplished:

$header = @{ "X-Octopus-ApiKey" = $APIKey }
$artifactUrl = "$OctopusUrl/api/$SpaceId/artifacts?take=2147483647&regarding=$ProjectId&order=dec"
$artifactResponse = Invoke-RestMethod $artifactUrl -Headers $header

APIKey, ProjectId, SpaceId, and OctopusUrl you will have to supply. You can get the project Id of Project A from [Octopus.Action[STEPNAME IN PROJECTB THAT DEPLOYS PROJECTA].DeployRelease.ProjectId] from within Project B. You can get SpaceId from [Octopus.Space.Id].

Once you have artifactresponse, the first artifact should be the latest but putting some checks in there is suggested. Iterate through to get the artifact ID. You will take the desired artifact ID, and you will then Get-Content on that (api/SPACEID/artifacts/ARTIFACTID/content) and do whatever FTP work needs to be done.

If you only apply the above logic, you will have to create a release in Project A before creating a release and deploying Project B. Project B will only deploy a Project A release, not create the release. You can add a step before Step 1 and 2 in Project B that will create a new release if you want to automate it further. That will be done with API calls. Here is an example to get you started on creating a release with an API call if you want to go that way.

As always, please test all script recommendations we give you to make sure you are getting desired results before using in production.

Please let me know if this will work for you or if you need any further assistance.


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.