Redeploy latest release of a project using .NET client api

Hi,

As per the subject, I need to be able to redeploy the currently released version of our app via the .NET client. I’ve spent a bit of time poking around the API, but can’t figure out how to work out what the latest release was for the project. In the REST api there looks to be a /api/projects/pulse call which sounds like what i’m after, but I can’t see the equivalent in the .NET client.

Any tips?

Thanks.

Hi Marcus,

Thanks for reaching out. This code snippet will get you the latest release from a project and store it into the latestRelease variable

string baseUri = ""; // Octopus URL
string apiKey = ""; // Octopus API Key
string projectName = ""; // Project name

var endpoint = new Octopus.Client.OctopusServerEndpoint(baseUri, apiKey);
var repository = new Octopus.Client.OctopusRepository(endpoint);

var project = repository.Projects.FindByName(projectName);

var latestRelease = repository.Projects.GetReleases(project).Items.OrderByDescending(r => SemanticVersion.Parse(r.Version)).FirstOrDefault();

Hope that helps,

Dalmiro

Perfect, thanks!