Runbook "Download as JSON" generates error

We recently upgraded our Octopus Server to version 2020.3.2 but now it appears to have broke the Runbook “Download as JSON” functionality. Prior to this recent upgrade, I know the functionality was working because that’s how we have been saving off our jsons to source control.
To reproduce:

  1. Open project containing runbook
  2. Open runbook and navigate to Processes tab
  3. Click ellipse and select Download as JSON
  4. In Save As dialog leave leave defaults and click Save
  5. Note download reports “Failed - No file”
  6. Click ellipse and right-click on Download as JSON
  7. Select “Open link in new tab”
  8. Note new tab contains error message
    ex. “ErrorMessage”: “The resource ‘RunbookProcess-Runbooks-141’ was not found.”

Hi @dgschmitz,

Thanks for reaching out.

I did a quick repro and it looks to be a bug. I’ll pass this along to our engineers and I will update you as it progresses.

I’ve written a quick API script to workaround this for you while this gets worked on. You should just need to fill out the top 5 things and it will write-host the JSON of the runbook. You could also change it to an out-file if you prefer that. As always, please read and test scripts that we supply in a test environment as they are not guaranteed to work in every scenario.

$OctopusServerUrl = ""  #PUT YOUR SERVER LOCATION HERE. (e.g. http://localhost)
$ApiKey = ""   #PUT YOUR API KEY HERE
$spaceName = ""   #PUT SPACE NAME HERE
$projectName = "" #PUT PROJECT NAME HERE
$runbookName = "" #PUT RUNBOOK NAME HERE

Function Get-SpaceId {
    # Define parameters
    param(
        $Space
    )
    $spaceName = $Space
    $spaceList = Invoke-RestMethod "$OctopusServerUrl/api/spaces?Name=$spaceName" -Headers @{"X-Octopus-ApiKey" = $ApiKey }
    $spaceFilter = @($spaceList.Items | Where { $_.Name -eq $spaceName })
    $spaceId = $spaceFilter[0].Id
    return $spaceId
}
Function Get-OctopusProject {
    # Define parameters
    param(
        $OctopusServerUrl,
        $ApiKey,
        $ProjectName,
        $SpaceId
    )
    # Call API to get all projects, then filter on name
    $octopusProject = Invoke-RestMethod -Method "get" -Uri "$OctopusServerUrl/api/projects/all" -Headers @{"X-Octopus-ApiKey" = "$ApiKey" }

    # return the specific project
    return ($octopusProject | Where-Object { $_.Name -eq $ProjectName -and $_.SpaceId -eq $SpaceId})
}
Function Get-RunbookId {
    # Define parameters
    param(
        $Runbook,
        $ProjectId,
        $SpaceId
    )
    $runbookname = $runbook
    $runbookList = Invoke-RestMethod "$OctopusServerUrl/api/runbooks?Name=$runbookName" -Headers @{"X-Octopus-ApiKey" = $ApiKey }
    $runbookFilter = @($runbookList.Items | Where { $_.Name -eq $runbookName -and $_.ProjectId -eq $ProjectId -and $_.SpaceId -eq $spaceId })
    $runbookId = $runbookFilter[0].Id
    return $runbookId
}


$spaceId = Get-SpaceId -space $spaceName
$projectId = Get-OctopusProject -OctopusServerUrl $OctopusServerUrl -ApiKey $ApiKey -ProjectName $projectName -SpaceId $spaceid
$projectId = $projectId.Id
$runbookId = Get-RunbookId -Runbook $runbookName -ProjectId $projectId -SpaceId $spaceId
$runbook = Invoke-RestMethod "$OctopusServerUrl/api/$spaceId/runbookProcesses/RunbookProcess-$runbookId" -Headers @{"X-Octopus-ApiKey" = $ApiKey }
$json = $null
$json = $runbook | convertto-json -depth 10
write-host $json

Please feel free to reach out in the meantime and let me know if that workaround doesnt work for you.

Thanks,
Jeremy

Hi,

I’ve created an Issue you can subscribe to here:

Please let me know if the workaround works or if you have any other questions or concerns.

Thanks,
Jeremy

Thank you for confirming my issue and providing a quick and easy to use work-around.

Thanks,
Dave

1 Like

Hi Dave,

You’re very welcome!

I hope you have a great rest of your week.

Edit: FYI I did make a small edit to my script. I added space awareness to the function that gets the runbook Id. It should work without it but I wanted to make it space aware.

Thanks,
Jeremy

Hi @dgschmitz ,

I just wanted to reach out and let you know that we have flagged this as an issue with Octopus , but at this point we do not have capacity to assign an engineer to resolve the issue. We’ll keep the issue open, but unfortunately we can not provide any guidance as to when it will be resolved. I’m sorry for the inconvenience, and we do appreciate that you took the time to report the issue.

Regards Matt

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.