Error re-deploying a release from TeamCity


I’ve run across an issue attempting to re-deploy a release from TeamCity. I’m setting --force and I’ve defined the OctopusForcePackageRedeployment variable to “true” with no scope in my Octopus project. When TeamCity kicks off the deploy using Octo, it reports errors like

"Release number '1.1232.30' has already been used for this project, please choose a different version number."

Here is the full text of the call to octo.exe:

[00:42:58]Step 1/1: OctopusDeploy: Release (OctopusDeploy: Release) (1s) [00:42:58][Step 1/1] Octopus Deploy (1s) [00:42:58][Octopus Deploy] Running command: octo.exe create-release --server="http://octopus/" --apikey=SECRET --project="Redacted" --enableservicemessages --version="1.1232.30" --deployto="QA" --waitfordeployment --packageversion=1.1232.30 --force [00:42:58][Octopus Deploy] Creating Octopus Deploy release [00:42:58][Octopus Deploy] Octopus Command Line Tool, version [00:42:58][Octopus Deploy] [00:42:58][Octopus Deploy] Finding project: Redacted [00:42:58][Octopus Deploy] Handshaking with Octopus server: http://octopus/api [00:42:59][Octopus Deploy] Handshake successful. Octopus version:; API version: 2.0.0 [00:42:59][Octopus Deploy] Finding environments... [00:42:59][Octopus Deploy] Finding steps for project... [00:42:59][Octopus Deploy] Release plan for release: 1.1232.30 [00:42:59][Octopus Deploy] Steps: [00:42:59][Octopus Deploy] # Name Version Source [00:42:59][Octopus Deploy] --- ------------------------------ --------------- ------------------------------------ [00:42:59][Octopus Deploy] 1 Deploy TeamCity build NuGet package 1.1232.30 User specified [00:42:59][Octopus Deploy] [00:42:59][Octopus Deploy] Creating release... [00:42:59][Octopus Deploy] Bad request { [00:42:59][Octopus Deploy] "errors": [ [00:42:59][Octopus Deploy] "Release number '1.1232.30' has already been used for this project, please choose a different version number" [00:42:59][Octopus Deploy] ] [00:42:59][Octopus Deploy] } [00:42:59][Octopus Deploy] System.Exception: Bad request { [00:42:59][Octopus Deploy] "errors": [ [00:42:59][Octopus Deploy] "Release number '1.1232.30' has already been used for this project, please choose a different version number" [00:42:59][Octopus Deploy] ] [00:42:59][Octopus Deploy] } [00:42:59][Octopus Deploy] at OctopusTools.Client.OctopusSession.ReadResponse(WebRequest request) [00:42:59][Octopus Deploy] at OctopusTools.Client.OctopusSession.Create[TResource](String path, TResource resource) [00:42:59][Octopus Deploy] at ProjectExtensions.CreateRelease(IOctopusSession session, Project project, IList1 latestVersions, String version, String releaseNotes) [00:42:59][Octopus Deploy] at OctopusTools.Commands.CreateReleaseCommand.Execute() [00:42:59][Octopus Deploy] at OctopusTools.Infrastructure.CommandProcessor.Process(String[] args) [00:42:59][Octopus Deploy] Octo.exe exit code: 2 [00:42:59][Step 1/1] Unable to create or deploy release. Please check the build log for details on the error. [00:42:59][Step 1/1] Step OctopusDeploy: Release (OctopusDeploy: Release) failed

Can anyone tell me what I’m doing wrong here? Thanks in advance!


Hi Nate,

As the error says, you already have a release with the same number. If you open your project in Octopus, and go to the Releases tab, you’ll find the release there. You can’t have more than one release with the same number, as it wouldn’t make sense. --force etc. doesn’t have any effect on this.

Are you incrementing the build number in TeamCity every time you call Octo.exe?


Hi Paul,

Thanks for your response. I guess I thought “force redeployment of already installed packages” would actually re-deploy a release. I’m left wondering what that flag does actually do - is it only dealing with the NuGet package version?

The use case is this: in TeamCity I have 2 linked build configurations, one to build the project and one to deploy with Octopus. There is a snapshot dependency set up and the version numbers are kept in sync. If I want to re-run the deploy build configuration to test something in the deploy pipeline only it won’t work currently if you have the TeamCity flag “Do not run new build if there is a suitable one” checked.

I’d like to be able to re-use a release number to work on the deployment part of the equation, without the need to re-build the NuGet package - I just want to re-deploy the same code, and we want the build & deploy versions to match. It sounds like this is currently not possible? This would be helpful, especially for projects that take a long time to build. Waiting on the dependency to build every time really slows down the trial & error process.



Thanks for sharing the scenario. I’ll look into adding some kind of “re-use release” checkbox in our TeamCity plugin so that if the release does exist it can be overwritten.


Hi Paul,

Thanks, that would be useful.


Hi Paul,

Has there been any progress on that feature? It would be incredibly helpful since I seem to come across this on every project!

I’m curious what the implications are around what packages would get used though. If you re-ran a build then it may have re-generated the package - would that package get used or would Octopus have cached the previous package?

+1 for “re-use release” checkbox in our TeamCity plugin

Hi Matt & Rob,

We have an --ignoreexisting flag you can set which should be what you are after.

Hope this helps!

Thanks for that. I literally just had a situation where I needed it again :slight_smile:

It worked in that the deployment succeeded, which is great, however the effect it has is that the deployment doesn’t proceed at all. Can a switch be added that creates a new release (maybe with a _1, _2 etc. at the end to make the number unique) so a deployment actually happens?