Using the API to retrieve a list of recently failed deploys


I understand using something like this:

will retrieve a list of failed deployments. We have a huge number of deploys and I’m hoping I can do something like:

  1. Get the most recent deployment failures
  2. Get the list of deployments that recently failed (were successful before)

Additional details that would be helpful would be details like who triggered the deploy.

I’ve been digging through documentation and navigating through the /api tree in the browser but can’t find a solution.

Is there one available?

Hi Tobin,

Thanks for reaching out!

The /deployments api doesn’t have a filter for date, but it has take which allows you to decide how many deployments to want to retrieve.

As for getting the name of the user who triggered the deployment, that info will be on the Event related to that deployment.

I’d recommend you to take a look at Octoposh which has a cmdlet called Get-OctopusDeployment that could help you here.

The cmdlet has a -before and -after filter that you can use to decide how far back in time you want to fetch deployments. While it doesn’t have a filter for “status”, the object it returns does have a Status property that you can filter once you have the deployments in memory. The below example shows how the object returned by this cmdlet looks like:

ProjectName         : Files
EnvironmentName     : Dev
DeploymentStartTime : 05/05/2017 1:21:39 PM
DeploymentEndTime   : 05/05/2017 1:22:10 PM
DeploymentStartedBy : dalmiro.granias@NY.local
Id                  : Deployments-3724
Duration            : 00:00:31
Status              : Success
ReleaseVersion      : 2.0.16
ReleaseCreationDate : 05/05/2017 1:21:36 PM
ReleaseNotes        :
ReleaseCreatedBy    : dalmiro.granias@NY.local
Packages            : {TestPush}
Resource            : Octopus.Client.Model.DeploymentResource

You’ll notice that It also shows who created the release and the deployment.

You can find the doc for that cmdlet over here:

Let me know if that helps,

Thank you for the quick reply Dalmiro. We have a massive amount of
deployments (in the thousands). We are automating the build and tear down
of many environments, platforms and deployments.

I looked at Octoposh and the source and appreciate what is being done
there. I can get to what I need by processing these most likely, but
there will be a lot of noise.

In CI/CD scenarios, designers of the system very much want to see
deployments that WERE working and are recently broken so that we can halt
the pipeline and get the responsible party to fix it.

TeamCity has a neat solution for it in their API:

This way you can get to a “clean” state and then turn on monitoring like
this to keep the CI/CD pipeline clean.

Ideally, I would love to see something like a “previousState” parameter in
the deployments API template like this:


I think it is justified because many large deployment pipelines will have
many failures, but there are only certain ones you care about.


Hi Tobin,

I can see how that feature would come in handy. Is there any chance you can submit that idea in Uservoice? If enough users in the community back that idea, we could definitely consider it for future updates.

For the time being in the current state of our API, I’m afraid the above suggestion is the only one available.