Teamcity triggering 2 deployments in Octopus

I have discovered something very strange in the past couple of days when I was converting our deployment scripts to Octopus Deploy (2.6.5.1010).
We are triggering our Octopus deployments via the Teamcity plugin (2.5.4.35) via a build step.
In this build step we are using the following settings:

Runner type: OctopusDeploy: Create release
Octopus URL: http://[ipaddress]:8181/
API key: ********
Octopus version: 2.0+
Project: %OctopusProject%
Release number: %build.number%
Deploy to: Dev
Show deployment progress: True
Additional command line arguments: --deploymenttimeout=00:30:00

We’ve upped the default timeout, because a single (Azure) deployment takes about 13 to 17 minutes to complete for our projects.
The thing we are running into at the moment is a deployment is triggered twice (2 times). The first deployment in Octopus is (probably) triggered when creating the release. The second deployment happens when the script is sees the earlier deployment is finished. Below is an excerpt of the build log.

[10:27:05]Step 5/5: Create and deploy release (OctopusDeploy: Create release) (26m:54s)
[10:27:06][Step 5/5] Octopus Deploy (26m:54s)
[10:27:06][Octopus Deploy] Running command:   octo.exe create-release --server http://[ipaddress]:8181/ --apikey SECRET --project Analytics Server --enableservicemessages --version 3.0.7 --deployto Dev --progress --deploymenttimeout=00:30:00
[10:27:06][Octopus Deploy] Creating Octopus Deploy release
[10:27:06][Octopus Deploy] Octopus Deploy Command Line Tool, version 2.5.3.33
[10:27:06][Octopus Deploy] 
[10:27:06][Octopus Deploy] Handshaking with Octopus server: http://192.168.70.8:8181/
[10:27:07][Octopus Deploy] Handshake successful. Octopus version: 2.6.5.1010; API version: 3.0.0
[10:27:07][Octopus Deploy] Finding project: Analytics Server
[10:27:07][Octopus Deploy] Finding deployment process for project: Analytics Server
[10:27:07][Octopus Deploy] Finding release template...
[10:27:08][Octopus Deploy] Resolving NuGet package versions...
[10:27:08][Octopus Deploy] Finding latest NuGet package for step: Analytics Server - West EU
[10:27:08][Octopus Deploy] Finding latest NuGet package for step: Analytics Server - East US
[10:27:08][Octopus Deploy] Using version number provided on command-line.
[10:27:08][Octopus Deploy] Release plan for release:    3.0.7
[10:27:08][Octopus Deploy] Steps: 
[10:27:08][Octopus Deploy]   #   Name                         Version         Source                              
[10:27:08][Octopus Deploy]   --- ---------------------------- --------------- ------------------------------------
[10:27:08][Octopus Deploy]   1   Analytics Server - West EU   3.0.7           Latest available in NuGet repository
[10:27:08][Octopus Deploy]   2   Analytics Server - East US   3.0.7           Latest available in NuGet repository
[10:27:08][Octopus Deploy] 
[10:27:08][Octopus Deploy] Creating release...
[10:27:09][Octopus Deploy] Release 3.0.7 created successfully!
[10:27:09][Octopus Deploy] ##teamcity[setParameter name='octo.releaseNumber' value='3.0.7']
[10:27:10][Octopus Deploy] Deploying Analytics Server 3.0.7 to: Dev (Guided Failure: Not Enabled)
[10:27:10][Octopus Deploy] Waiting for 1 deployment(s) to complete....
[10:42:00][Octopus Deploy] Success: Step 1: Check Azure environment
[10:42:00][Success: Step 1: Check Azure environment] Executing step: Check Azure environment
[10:42:00][Success: Step 1: Check Azure environment] Success: Tentacle01
[10:42:00][Success: Tentacle01] Running "Check Azure environment" on "Tentacle01"
[10:42:00][Success: Tentacle01] Success: Tentacle script execution
[10:42:21][Octopus Deploy] Success: Acquire packages
[10:42:21][Success: Acquire packages] Downloading packages
[10:42:21][Success: Acquire packages] Making a list of packages to download
[10:42:21][Success: Acquire packages] All packages have been downloaded
[10:42:21][Success: Acquire packages] Success: Package MyCustomer.Azure.AnalyticsServer 3.0.7 from NuGet feed: Teamcity packages
[10:47:55][Octopus Deploy] Success: Step 2: Analytics Server - West EU
[10:47:55][Success: Step 2: Analytics Server - West EU] Executing step: Analytics Server - West EU
[10:47:55][Success: Step 2: Analytics Server - West EU] Running "Analytics Server - West EU" on "Tentacle01"
[10:47:55][Success: Step 2: Analytics Server - West EU] Success: Deploy MyCustomer.Azure.AnalyticsServer on Tentacle01
[10:54:00][Octopus Deploy] Success: Step 3: Analytics Server - East US
[10:54:00][Success: Step 3: Analytics Server - East US] Executing step: Analytics Server - East US
[10:54:00][Success: Step 3: Analytics Server - East US] Running "Analytics Server - East US" on "Tentacle01"
[10:54:00][Success: Step 3: Analytics Server - East US] Success: Deploy MyCustomer.Azure.AnalyticsServer on Tentacle01
[10:54:00][Octopus Deploy] Deploy Analytics Server release 3.0.7 to Dev: Success
[10:54:00][Octopus Deploy] Done!
[10:54:00][Octopus Deploy] Octo.exe exit code: 0

As you can see, there’s a time gap between the following lines:

[10:27:10][Octopus Deploy] Waiting for 1 deployment(s) to complete....
[10:42:00][Octopus Deploy] Success: Step 1: Check Azure environment

At 10:27 a deployment is started and at 10:42 another one starts.

I can’t seem to figure out how I would be able to fix this, because it appears to be out of my hands. But if this would be the case, a lot of other people would probably have the same issue. Therefore it’s probably something in the current configuration, but I’m a bit lost at the moment.

PS: In Octopus Deploy I can see there’s 1 release which is deployed twice.

Hi,

Thanks for reaching out. Is it possible that you have the environment dev set to be deployed as soon as the release gets created? This might be causing deployment #1, and then your TC step would be causing step #2

You can check this by opening the your lifecycle and checking if that environment is on the first phase, and it has a lightning icon on it (Like the environment development on the attached screenshot).

If unsure, send us a screenshot of your lifecycle just like the one i’ve attached.

Thanks!

Dalmiro

Wow, this was indeed the case.
I was already wondering what this lighting icon meant. Fixed this by removing the dev environment from the lifecycle and re-adding it again.

Cheers!

Jan

Hi Jan,

Glad you got it working even though i forgot to attach the screenshot! Adding it now for reference to any other user that reaches this topic

Cheers!

Dalmiro

lifecycle.JPG

Suppose you want TeamCity to just “Create Release” like the build step is called, and not actually release it.

Personally I see Octopus as the place this should be configured, as you’ve said, in the channels.

Is there a way of setting it up like this? I’d like TeamCity to just create a release, but not actually release it!

Hi Matt,

Thanks for reaching out! It sounds like what’s happening is in the Create Release section of TeamCity, the Deploy To field is populated (see attached screenshot). This option allows you to automatically deploy the release once it’s created. You can remove that, and it won’t deploy automatically :slight_smile:

I hope that helps!

Kenny