The progression api

Hi there

I’m looking to use the api to figure out:
a) what environments a project has been deployed to
b) has there ever been a successful deployment to that environment, and if so, when was it

At this point, I’m looking at the iterating through the deployments api, but that is a bit painful, especially as i dont know if there has ever been a deployment to a specific environment, so I have to page through all results.

I’ve looked at the progression api but i’m not sure exactly how it works. Can you clarify if it will always show the latest succesful release to an environment if one exists?

I took a look at https://github.com/OctopusDeploy/OctopusDeploy-Api/wiki/Progressions, but its a bit sparse on details.

Thanks,
Matt

Hi Matt,

Thanks for reaching out. Before getting our hands dirty with the API, I wanna bring to your attention an OSS project called Octoposh that might be just what you need. It’s a Powershell module that contains several cmdlets that’ll help you get information from (among other things).

There’s a cmdlet called Get-OctopusDeployment on that module that’ll return plenty of info about deployments. Using this cmdlet you can filter by Project, Environment, date of execution, status, and a couple other things. See the attached screenshot for a very brief example.

Project website: http://octoposh.net/

Let me know if this helps,
Dalmiro

Hi Dalmiro

Thanks for that. That looks quite interesting, but I’m not sure it will help in this situation.

I’m currently in the fun land of java, writing a team city plugin (https://github.com/matt-richardson/teamcity-octopus-build-trigger-plugin), so neither the powershell nor .net client will be much of a help.

At the moment, I’m iterating through the deployments, which is a bit painful, especially in the scenario that there has been no deployments to an environment – I end up paging all the way through.

Cheers,
Matt

Hi Dalmiro

A potential bug I’ve just noticed is that the progression api doesn’t appear in the links on the root listing of the api.

Cheers,
Matt

From: Matt Richardson matt.richardson@devopsguys.com
Date: Thursday, 14 January 2016 at 22:13
To: Dalmiro Grañas tender2+d593ff6d36@tenderapp.com
Subject: Re: The progression api [Questions #7003]

Hi Dalmiro

Thanks for that. That looks quite interesting, but I’m not sure it will help in this situation.

I’m currently in the fun land of java, writing a team city plugin (https://github.com/matt-richardson/teamcity-octopus-build-trigger-plugin), so neither the powershell nor .net client will be much of a help.

At the moment, I’m iterating through the deployments, which is a bit painful, especially in the scenario that there has been no deployments to an environment – I end up paging all the way through.

Cheers,
Matt

Hi Matt,

Sorry for the delay here. I’ll get back to you tomorrow morning with the details of the REST calls that could help you with this.

Regards,
Dalmiro

Hi Dalmiro

Any progress on this one?

Thanks,
Matt

Hi Matt,

Very sorry for the delay here.

A) what environments a project has been deployed to

You can see this information from the Web portal on the dashboard. To render that site, we do a get to /api/dashboard . Take a few minutes to dig into the results of this API call and you’ll find out what you are looking for.

B) has there ever been a successful deployment to that environment, and if so, when was it

This one is a bit trickier and will require a few more API calls. I’m gonna assume you wan’t the latest successful deployment for an environment.

  1. GET /api/deployments?environments=Environments-1&projects=Projects-101 where environments-21 is the ID of your environments and Projects-101 is the ID of your project.

  2. Te call above will return something similar to this:

ItemType     : Deployment
IsStale      : False
TotalResults : 40
ItemsPerPage : 30
Items        : {Lots of deployments}
Links        : @{Self=/api/deployments?projects=Projects-101&environments=Envir
               onments-1; Template=/api/deployments{?skip,take,projects,environ
               ments,taskState}; Page.Current=/api/deployments?skip=0&projects=
               Projects-101&environments=Environments-1; Page.0=/api/deployment
               s?skip=0&projects=Projects-101&environments=Environments-1; Page.Next=/api/deployment
               s?skip=30&projects=Projects-101&environments=Environments-1}

As you can see, it is only showing 30 results out of the 40 that exist on database. To get the following set of 30 results, you’re gonna hace to check on the link property for the link called Page.next. The logic should go a bit like this:

  • Get first 30 results
  • Check if there’s a Successful deployment in them (the results come sorted by time created descending). If there is one keep it and stop the process
  • If there wasn’t a successful deployment, check the next 30. Repeat process.

Hope that helps,

Dalmiro

Hi Dalmiro

Thanks for that.

Can you tell me how this compares to using the progression api? It appears that the progression api gives me most of this information as well?

What I’ve implemented so far uses the progression api as a first call, then falls back to the deployments api if it can’t find a successful deployment.

Am I understanding the progression api correctly? Or are there underlying implementation details that mean it doesn’t quite work the way I think it does?

Thanks,
Matt

Hi Matt,

The progression API belongs to older versions of Octopus, and its no longer being used in 3.0 (unless I’m terribly wrong). I’d recommend you to follow the approach I described on my previous reply, as It applies to both 2.x and 3.x versions of Octopus.

Regards,
Dalmiro

Hi Dalmiro

Ahh - that’s interesting.

I found the progression api by watching the network calls - it’s used on the project overview page, even in 3.2.

Is there intent to deprecate that call?

Cheers,
Matt

Hi Matt,

I must admit I thought we deprecated that API (haven’t checked on it since 2.6 I think), but i believe we improved it instead somewhere between 2.6 and 3.2.

That one is not going away anytime soon, so feel free to keep using it if its giving you the info you need.

Best regards,
Dalmiro

Hi Dalmiro

Thanks for the confirmation that its going to stick around.

I’d still like to know a few things though:

  • Can you clarify if the progression api will always return the latest successful deployment to an environment, if one exists? Or is there some edge case where there has been a successful deployment, but many subsequent failing ones, and it wont return the successful one?
  • is the missing progression link in the /api response a bug? Or by design? (I’d like to follow RESTful principles and navigate via the links where possible).

Thanks,
Matt

1 Like

Hi Matt,

That is correct, It should always return the latest successful deployment.

I’ll ask around if we should add /api/progression/{project ID}. Where would you expect to see it? As a link that belongs to the project?

Thanks,
Dalmiro

Hi Dalmiro

Thanks for that.

Re the progression link – it is already a child of the project. I was assuming that it should be on the root api list, but recently I’ve started to question my assumption.
But… It appears nearly all the other links under projects are also listed under the root api link.

I will leave it with you guys to decide how you want to handle it. Happy to close this call.

Cheers,
Matt