How to get running tasks count from octopus.client

Hi! How to get count of a running tasks via octopus.client?

Through the rest api it seems like api/tasks?running=True, but i cant find same method in a client…

Hi!

Thanks for reaching out! That’s a great question. We don’t have a script to see currently running tasks documented in our Octopus.Client API documentation. Here’s a PowerShell script I wrote which will retrieve that same information as the API link you mentioned:

Add-Type -Path 'Octopus.Client.dll' 

$apikey = 'API-xxx' #Your API Key
$octopusURI = 'http://localhost' # Your server address

$endpoint = new-object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey 
$repository = new-object Octopus.Client.OctopusRepository $endpoint

$repository.Tasks.FindMany(
    {param($endpoint) if ($endpoint.State -eq "Executing"){
        $true
        }
    })

I hope that helps!

Kenny

Thank you for the answer. I know about this workaround, but this solution running very long (more than 5 minutes) and this is unacceptable

Hi,

Thanks for following up. Sadly, there isn’t a more optimal way to retrieve running tasks via the Octopus.Client. If you need a better performance solution, I’d recommend calling the REST API and deserializing the results.

Kind regards,

Kenny

Ok, i understood.

Is there in a future plans to add this option to the client?

Hi,

We don’t have any plans to add this to the Octopus.client. Though, since the Octopus.client repository is open source, you’re welcome to make the change yourself and feel free to submit a pull request to us. Alternatively, you could submit this as a UserVoice suggestion as this helps us prioritise new features and updates in the future.

Kind regards,

Kenny