Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Unable to retrieve version controlled Runbooks from Octopus Client

Open susanpann opened this issue 6 months ago • 0 comments

Severity

Low

Version

Customer on Client v15.1.2168, could repro on v15.2.2178

Latest Version

None

What happened?

Cannot retrieve CaC runbooks from Octopus Client using powershell. Have confirmed that it works in C#.

The URL that gets created: ~/api/Spaces-1/runbooks?ids=Octopus.Client.Model.ProjectResource,refs%252Fheads%252Fmain,asd

Reproduction

  1. Create a git runbook in Octopus Server
  2. Create a powershell script and attempt to retrieve the git runbook
  3. See that no runbooks are retrieved

Error and Stacktrace


More Information

Example Script

Add-Type -Path "\path\to\Octopus.Client.dll"

$octopusUrl = "OCTOPUS_URL"
$octopusApiKey = "API-123456789"
$spaceName = "space"
$projectName = "project-name"
$runbookSlug = "runbook-slug"
$gitRef = "refs%2Fheads%2Fmain"

$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusUrl, $octopusApiKey
$client = [Octopus.Client.OctopusAsyncClient]::Create($endpoint).Result
$repository = New-Object Octopus.Client.OctopusAsyncRepository $client

try
{
    $spaceRepo = $repository.Spaces.FindByName($spaceName).Result
    $spaceClient = $client.ForSpace($spaceRepo)
    
    $project = $spaceClient.Projects.FindByName($projectName).Result
    Write-Host $project.SpaceId
    Write-Host $project.Id
    Write-Host $project.Links.Runbooks

    $runbook = $spaceClient.Runbooks.Get($project, $gitRef, $runbookSlug, $null).Result
    Write-Host $runbook
}
catch
{
    Write-Host $_.Exception.Message
}

Workaround

No response

susanpann avatar Jun 18 '25 02:06 susanpann