Octo.exe, the command-line tool for automating Octopus Deploy, now has two new commands: export and import

These commands can be used in scenarios where you have multiple Octopus Deploy servers in different locations. For example, one Octopus server is used to setup and test new projects prior to creating them on a second Production server, located on a completely different, isolated network. Previously, if you wanted to sync the two servers, you had to manually recreate the projects and releases that you have created on your test server.

Currently we support exporting and importing:

  • A project and any dependencies
  • A release or range of releases of a project

Exporting

Command Usage

Exporting a project

Let's imagine that you have the following projects setup and deploying on a test Octopus Deploy server and you want to copy the OctoFX Rate Service projects to your production Octopus Deploy server.

Dashboard

To export the OctoFX Rate Service project, you would execute the following command from a command prompt:

octo export --server=http://octopusserver/ --apiKey=API-EXPORTERAPIKEY --type=project --name="OctoFX Rate Service" --filePath="C:\path\to\export\file.json"

The command will connect to the Octopus server, fetch all the information, and write it to a JSON file. You can learn more about what's included in the file in the documentation.

Exporting a release, or a range of releases for a project

Releases

To export a release for the OctoFX Rate Service project, you would execute the following command from a command prompt:

octo export --server=http://octopusserver/ --apiKey=API-EXPORTERAPIKEY --type=release --project="OctoFX Rate Service" --releaseVersion=2.7.2067 --filePath="C:\path\to\export\file.json"

Or for a range of releases:

octo export --server=http://octopusserver/ --apiKey=API-EXPORTERAPIKEY --type=release --project="OctoFX Rate Service" --releaseVersion=2.7.2063-2.7.2067 --filePath="C:\path\to\export\file.json"

The command will connect to the Octopus server, fetch the release, and write it to a JSON file. You can learn more about what's included in the file in the documentation.

Importing

Command Usage

Importing a project

When importing a project into another Octopus Deploy server the following has to already exist in the Octopus Deploy server being imported to:

  • The Project Group used by the Project
  • The Environments used in the Project
  • The Machines used in the Project
  • The NuGet feeds used in the Project
  • The Library Variable Sets (if any) used in the Project

Once these prerequisites are met, to import the OctoFX Rate Service that we exported in the previous example, you would execute the following command from a command prompt:

octo import --server=http://octopusserver --apiKey=API-IMPORTERAPIKEY --type=project --filePath="C:\path\to\export\file.json"

And if a prerequisite is missing the output should be something similar to Project Import Output when prerequisite is missing

Otherwise, the output should be something similar to Project Import Output

If there are variables in the Project that are marked as Sensitive (i.e. Passwords), you will receive a warning in the output informing you that you will have to update the value through the UI before it can be used, as we do not export the value of sensitive variables.

And in Octopus Deploy you should now see the project that you imported.

Dashboard

Importing a release/range of releases

When importing a release, or range of releases, the project must exist on the Octopus Deploy where the import is run on.

To import a release, or range of releases, for a project you run the following command:

octo import --server=http://octopusserver/ --apiKey=API-IMPORTERAPIKEY --type=release --project=projectname --filePath=C:\path\to\export\file.json

And the output should be something similar to Release Import Output

If you now go to the Release tab on the Project page, you should see the new releases that were just imported.

Project Releases

Summary

Hopefully you'll find this a useful tool for migrating projects/releases between Octopus servers. While this tool is meant to be usable for many scenarios, it's quite possible that your scenario might be different. Keep in mind that Octo.exe is open source - feel free to use it as a starting point, and to customise and expand it to suit your needs.


Octopus Deploy is used by thousands of developers across the globe, from small companies to large enterprises. Find out if it meets your deployment automation needs by taking advantage of our free 30-day trial. You can spin up an instance with just a few clicks!

Walkthrough