OK, so I can get a list of releases for a particular project like this:
http://octopus.myinstance.com/api/projects/Projects-244/releases?apikey=API-SOMEAPIKEY
Note the “Projects-244”. Is it possible to do this specifying the name of the project instead instead?
Dalmiro
(Dalmiro Grañas)
2
Hi,
Thanks for reaching out. Its not possible to do this just specifying the project name.
You can do it in 2 ways:
The raw API way: First you gotta get the project all the projects from /api/projects/all
, filter the one you want by name and get its ID.
The Powershell way: Use the cmdlet Get-OctopusRelease
from the open source module Octoposh, which has a -ProjectName
parameter.
Octoposh site: http://octoposh.net/
Cmdlet wiki: https://github.com/Dalmirog/OctoPosh/wiki/Get-OctopusRelease
Hope that helps,
Dalmiro
Excellent, thanks Dalmiro.
For those that want to know, in Powershell you do something like this:
$projectName=“MyProject”
$octopusUrl="http://octopus.myinstance.com/api/projects/all?apikey=API-SOMEAPIKEY
$projects=Invoke-RestMethod -Method Get -Uri $octopusUrl
ForEach($project in $projects){
if($project.Name.contains($projectName)){
Write-Output ("Found project: {0},{1}" -f $project.Name, $project.Id)
break
}
}
1 Like