Octopus deployment exit code -1 from octo.exe via TeamCity

Hi there,
so i’ve configured TeamCity to deploy to octopus but it’s returning an error from octo.exe:

[Octopus Deploy] Release '1.0.10' of project 'API' cannot be deployed to environment 'API Production' because the environment is not in the list of environments that this release can be deployed to. This may be because a) the environment does not exist, b) the name is misspelled, c) you don't have permission to deploy to this environment, or d) the environment is not in the list of environments defined by the lifecycle. [14:36:19][Octopus Deploy] Exit code: -1

however the application is successfully deploying, and octopus is reporting all OK - just wondering if anyone has had this issue before?
running the latest versions of octopus and TeamCity

Hi Jesse,

Thanks for getting in touch! Are you using deploy-release or create-release for this process? Feel free to send me the build log and I can have a look for you if you like.

Generally this occurs when create-release is used with deploy-to and trying to deploy to a phase in your lifecycle that is gated by previous phases.

Let me know what you find
Vanessa

Hi Vanessa, thanks for the quick reply! :slight_smile:
Below are the logs. We’re using create-release, our lifecycle only has one phase though.

Step 3/3: Create release (OctopusDeploy: Create release) (1s)
[16:14:06][Step 3/3] Octopus Deploy (1s)
[16:14:06][Octopus Deploy] Running command: octo.exe create-release --server http://deploy.wge.com.au/ --apikey SECRET --project API --enableservicemessages --version 1.0.18 --channel Default --deployto API Production --progress
[16:14:06][Octopus Deploy] Creating Octopus Deploy release
[16:14:06][Octopus Deploy] Octopus Deploy Command Line Tool, version 3.3.2+Branch.master.Sha.497e7f8ef2b193cd33560217bfecc38d721029a5
[16:14:06][Octopus Deploy]
[16:14:06][Octopus Deploy] Handshaking with Octopus server: http://deploy.wge.com.au/
[16:14:06][Octopus Deploy] Handshake successful. Octopus version: 3.2.21; API version: 3.0.0
[16:14:06][Octopus Deploy] Authenticated as: Jesse Millman jesse.millman@wge.com.au
[16:14:06][Octopus Deploy] Finding project: API
[16:14:06][Octopus Deploy] Finding channel: Default
[16:14:06][Octopus Deploy] Finding deployment process for project: API
[16:14:06][Octopus Deploy] Finding release template…
[16:14:06][Octopus Deploy] Resolving NuGet package versions…
[16:14:06][Octopus Deploy] Finding latest NuGet package for step: Deploy
[16:14:07][Octopus Deploy] Using version number provided on command-line.
[16:14:07][Octopus Deploy] Release plan for release: 1.0.18
[16:14:07][Octopus Deploy] Steps:
[16:14:07][Octopus Deploy] # Name Version Source
[16:14:07][Octopus Deploy] — -------- --------------- ------------------------------------
[16:14:07][Octopus Deploy] 1 Deploy 1.0.17 Latest available in NuGet repository
[16:14:07][Octopus Deploy]
[16:14:07][Octopus Deploy] Creating release…
[16:14:07][Octopus Deploy] Release 1.0.18 created successfully!
[16:14:07][Octopus Deploy] ##teamcity[setParameter name=‘octo.releaseNumber’ value=‘1.0.18’]
[16:14:07][Octopus Deploy] Release ‘1.0.18’ of project ‘API’ cannot be deployed to environment ‘API Production’ because the environment is not in the list of environments that this release can be deployed to. This may be because a) the environment does not exist, b) the name is misspelled, c) you don’t have permission to deploy to this environment, or d) the environment is not in the list of environments defined by the lifecycle.
[16:14:07][Octopus Deploy] Exit code: -1
[16:14:07][Octopus Deploy] Octo.exe exit code: -1
[16:14:07][Step 3/3] Unable to create or deploy release. Please check the build log for details on the error.
[16:14:07][Step 3/3] Step Create release (OctopusDeploy: Create release) failed

Hi Jesse,

Could you check a few things for me, it turns out its case sensitive for environment names. Can you check that your environment is exactly ‘API Production’? If it is could you wrap it in quotes? ie "API Production"

Let me know if that helps or not
Vanessa

Awesome, putting the quotes around it has resolved the error, thanks so much for your assistance Vanessa!

Hi Jesse,

Great to hear it!

Vanessa

Hi vanessa,

we are also facing the same issue. we tried the solution you have mentioned in your post but it didn’t work for us.

Can you please suggest us anything other than the previous solution?
here is our build log… we are using Deploy Release for Staging environment (as we have used create Release for our QA environment)

[19:04:12]Step 4/4: Deploy to Staging (OctopusDeploy: Deploy release) (2s)
[19:04:12][Step 4/4] Octopus Deploy (2s)
[19:04:12][Octopus Deploy] Running command: octo.exe deploy-release --server http://localhost:8080/ --apikey SECRET --project Test --enableservicemessages --version 1.0.229 --deployto “Staging”
[19:04:12][Octopus Deploy] Deploying Octopus Deploy release
[19:04:13][Octopus Deploy] Octopus Deploy Command Line Tool, version 2.5.3.33
[19:04:13][Octopus Deploy]
[19:04:13][Octopus Deploy] Handshaking with Octopus server: http://xyz:8080/
[19:04:14][Octopus Deploy] Handshake successful. Octopus version: 3.1.5; API version: 3.0.0
[19:04:14][Octopus Deploy] Finding project: Test
[19:04:14][Octopus Deploy] Finding release: 1.0.229
[19:04:14][Octopus Deploy] Release ‘1.0.229’ of project ‘Test’ cannot be deployed to environment ‘Staging’ because the environment is not in the list of environments that this release can be deployed to. This may be because a) the environment does not exist, b) the name is misspelled, c) you don’t have permission to deploy to this environment, or d) the environment is not in the list of environments defined by the project group.
[19:04:14][Octopus Deploy] Exit code: -1
[19:04:14][Octopus Deploy] Octo.exe exit code: -1
[19:04:14][Step 4/4] Unable to create or deploy release. Please check the build log for details on the error.
[19:04:14][Step 4/4] Step Deploy to Staging (OctopusDeploy: Deploy release) failed
[19:04:14]Publishing internal artifacts
[19:04:14][Publishing internal artifacts] Sending using WebPublisher
[19:04:14][Publishing internal artifacts] Sending using ArtifactsCachePublisher
[19:04:15]Build finished

Hi Sanjay,

The second cause of this error when is you are trying to create a new release to an environment that isn’t in your first phase of your Lifecycle.
Could you provide a screenshot of your Project -> Process page if you cannot determine this yourself.

Vanessa

Hi Vanessa,

Thanks for replying. I have got the solution and it’s deploying to Staging now. But now I am facing another issue when trying to deploy the package to the server from octopus.
actually the version numbers are different for QA and Staging i.e QA has 1.0.2 and Staging has 1.0.1. while deploying process it’s picking the 1.0.2 (QA) package to deploy to the Staging.
Please find the screenshot here http://screencast.com/t/wA9NOFC6pPN

Thanks
Sanjay

Hi Sanjay,

Your screenshot should show deploy buttons if your Lifecycle and phases were ready for promotion.
Could you show me a screenshot of your releases for each of them. It should show available environments for promotion.

Vanessa

Hi Vanessa,

Thanks for replying. I gave got the solution and it’s working fine now.
Thanks again for your help.

Sanjay

Hi Sanjay,

Great to hear it! Happy deployments!

Vanessa