Cancel deployment if one in progress

Hi, we use Team City for our CI and on green builds, we deploy the app and performance tests via Octopus. Our build generally takes about 2 hours so each 2 hours we get a new app deployed and another performance test. The problem with the latter is it runs for about 12 hours so when we have contiguous green builds, the performance tests backup behind each other.

I checked the octo.exe help deploy-release output but cannot see anything obvious - what I would like to happen is when TeamCity calls the Deploy-Release runner, if there is already a performance test running then the new deployment shouldn’t be added. Is this possible with the Octo.exe tool?

Hi Gavin,

Thanks for getting in touch! Unfortunately queuing deployments is the standard and we don’t have a specific way (apart from writing a script) to stop deployments for an environment to queue. But we have an idea, how about if you were instead to use Create-Release, as this will give you the option to use --ignoreexisting
If ‘Create-Release’ finds the release # you gave it already exists the --ignoreexisting flag will both not create the release again and not deploy to the environment listed.
Below I have linked to the documentation on Create-Release also:

Please let me know if this helps.

Regards,
Daniel

Hi Daniel

Thanks for getting back to me. Unfortunately the release is a new number as the release number comes from the build number which is ever increasing. I will look into a script based solution.

Is there an API call I can make to a project that would return a true/false if it’s currently running a deployment?

Gavin

Hi Gavin,

So I had a chat with one of the devs and it looks like you can not do this directly. You can however under http://YourOctopusURL/api/deployments get a project id for your deployments that contain a link to the servertask which has a State which will be one of the following Queued, Executing, Failed, Canceled, TimedOut, Success or Cancelling.
So you could do something like fetch the deployments, filter down to just your project, then load the tasks and check the state.

Hope this helps :slight_smile:

Regards,
Daniel

Hi Daniel

That sounds great. It seems in a recent release though URL’s have stopped being the ID (e.g. /app/projects/project-1) and is now project name (e.g. /app/projects/project-name), where do I now find the project ID?

Thanks
Gavin

Hi Gavin,

Are you able to confirm that you are using /api the examples you sent me have /app

Looking forward to hearing from you.

Regards,
Daniel

Hi Daniel

Apologies for the delay, yes I meant /api sorry and it is all working now, so if the State does not equal Executing then I run the deployment else nothing happens for that build

Regards
Gavin

Hi Gavin,

I’m glad to hear it is working now.

If you run into any further issues or have any questions please feel free to get in touch.

Regards,
Daniel