How to make Octopus deploy choose package version in multiple environment?

Vagif Abilov picture Vagif Abilov · Jan 21, 2014 · Viewed 8.4k times · Source

We are building packages for multiple deployment environments using TeamCity server and OctoPack. The problem is that tentacle agent chooses the latest by number version of the package, so it's the same (latest) package that is deployed on all environments. Here's the summary of our setup:

  • Environments DEV and STAGE;
  • Deployment to DEV is triggered from Git "dev" branch;
  • Deployment to STAGE is triggered from Git "stage" branch;
  • OctoPack is configured to generate packages MyProduct.1.0.0.dev-%build_counter% for DEV build configuration;
  • OctoPack is configured to generated packages MyProduct.1.0.0.%build_counter% for STAGE build configuration;
  • TeamCity is configured to expose OctoPack artefacts (NuGet packages) via its NuGet feed;
  • Octopus project is configured to deploy packages with NuGet Id MyProduct from TeamCity NuGet feed.

So what happens is that since DEV builds are run more frequently, they have larger %build_counter%, and STAGE doesn't get a chance to get a deployment of its own packages - Octopus tentacle preferes packages with 1.0.0.dev-* suffix.

This must be fairly common scenario, but I haven't found a simple way to solve it.

Answer

Tomas Jansson picture Tomas Jansson · Jan 21, 2014

There are some parts that are not documented here: https://github.com/OctopusDeploy/Octopus-Tools. But if you look at https://github.com/OctopusDeploy/Octopus-Tools/blob/master/source/OctopusTools/Commands/CreateReleaseCommand.cs it is possible to figure out what you can do.

I think the tools is backward compatible, but not 100 % sure about that.

When you are using the octo tools, which I expect that you use, you can set the version (also called releasenumber now) option to specify the release number. If you doesn't specify anything else it will take the latest package so what you want to do is set the packageversion (also called defaultpackageversion now) that should be used for the release.

I think that should do it. If it doesn't, what are you using to create the release?

Example of what we are using from our TeamCity when using octo tools which we have added to the environment path on the build agents:

create-release --server=%conf.OctoServerApi% --project=%conf.OctoProject% --version=%env.OctopusPackageVersion% --deployto=%conf.OctoDeployEnv% --packageversion=%env.OctoPackPackageVersion% --apiKey=%conf.OctoApiKey% --waitfordeployment %conf.OctoExtraParams%

UPDATE:

The documentation for 2.0 is much better: http://docs.octopusdeploy.com/pages/viewpage.action?pageId=360596