Identify steps which use an external feed

We’re planning on retiring one of our nuget package feeds and replacing it which means we will have to update all of our “deploy” steps in all of our projects.
Is there an easy way to identify the steps which reference a feed?
This would help us identify any that have been missed before they break.
Many thanks

Hi Graham,

Thanks for getting in touch! Since the feed is stored in properties on each action (when you get the deployment process from the API, it’s Octopus.Action.Package.FeedId with the name of the feed), the easiest way to swap the feed for all steps using it would be to edit the existing one. It should automatically cascade through all steps that currently use that feed.

If you’ve already made a new feed and started updating the existing steps with it, you could iterate over the action properties to identify all of the steps.

I hope this helps! Don’t hesitate to reach out if you have any further questions.

Kind regards,

Kenny

Hi Kenny,

Thanks for the reply.

Unfortunately we need to leave the existing feed in place as it is still used on some projects.
Could you give me some more details on “get the deployment process from the API” please? Ideally I’d like to be able to get a list of all processes which still use a specific feedid.

I can see that I can get a list of projects, loop through the deployment processes, loop through the steps and then loop through the properties to find Octopus.Action.Package.FeedId but is there a better/faster way?

Many thanks

Hi Graham,

Thanks for following up! We don’t have anything built-in to do this specifically, so your comment to loop through everything will be the fastest way to find/update all steps that use this feed. We have some example scripts on manipulating deployment processes via the API in our API repository. You can check those out here. :slight_smile:

I hope this helps! Let me know if you have any further questions.

Kind regards,

Kenny

For anyone that comes across this in future, here’s some powershell to get the list of projects, steps which use a particular feed.

$octopusBaseUrl = "http://myoctopusserver"
$apiKey = "myapikey"
$feedName = "myfeed"
function Http-Get
{
    param( [Uri]$Uri )
    $headers = @{ "X-Octopus-ApiKey" = $apiKey }
    $url = "$octopusBaseUrl$Uri"
    return Invoke-RestMethod $url -Headers $headers -Method Get
}
 
(Http-Get "/api/projects/all") |
        foreach {
            $item = $_
            Http-Get $item.Links.DeploymentProcess
        } | foreach {
                $deploymentProcess = $_
                $deploymentProcess.Steps
            } | where {  Get-Member -InputObject  $_.Actions.Properties -Name 'Octopus.Action.Package.FeedId' -MemberType Properties } |
                Select-Object   @{ Name = "Project Name"; Expression = {$item.Name} },
                                @{ Name = "Step Name"; Expression = {$_.Name} },
                                @{ Name = "Feed Id"; Expression = {$_.Actions.Properties.'Octopus.Action.Package.FeedId'} } |
                                    where  { $_."Feed Id" -eq "feeds-$feedName" }
1 Like

Hi Graham,

That looks great! Thanks for taking the time to share your solution. I’m sure it’ll be helpful to others who need to do the same thing. :slight_smile:

Don’t hesitate to reach out if you have any questions going forward!

Best regards,

Kenny