Skip to content

Conversation

@BobJWalker
Copy link
Contributor

… trying to create snapshot

Ensured Get-RunbookPackages always returns an array when publishing a snapshot.

Tested with an unpublished runbook with and without a package


Background

Fixes issue #1607

Results

Fixes an issue when the following happens when using the run a runbook step

  • Using a non-published non-version controlled runbook
  • Configured the run a runbook step to not use a published snapshot
  • The runbook doesn't have any referenced packages

When those three items happen, the run a runbook step attempts to create a snapshot to use. Previously that would cause a 500 error because the API expects an array.

Before

Invoking POST https://myplatform.com/api/Spaces-1/runbookSnapshots 
NotSpecified: Error calling https://myplatform/api/Spaces-1/runbookSnapshots (SpaceId: Spaces-1; Body: '{ 
    "RunbookId":  "Runbooks-665", 
    "ProjectVariableSetSnapshotId":  "variableset-Projects-922", 
    "SelectedPackages":  { 
                         }, 
    "ProjectId":  "Projects-922", 
    "FrozenRunbookProcessId":  "RunbookProcess-Runbooks-665", 
    "FrozenProjectVariableSetId":  "variableset-Projects-922", 
    "Name":  "Snapshot B5FCNM2", 
    "LibraryVariableSetSnapshotIds":  [ 
                                          "LibraryVariableSets-122", 
                                          "LibraryVariableSets-61", 
                                          "LibraryVariableSets-21", 
                                          "LibraryVariableSets-41" 
                                      ] 
}') The remote server returned an error: (500) Internal Server Error. StatusCode: InternalServerError 
At C:\Octopus\Work\20250522142431-284517-1362\Script.ps1:348 char:20 
+ ... wSnapShot = Invoke-OctopusApi -octopusUrl $defaultUrl -apiKey $octopu ... 
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
at Invoke-OctopusApi, C:\Octopus\Work\20250522142431-284517-1362\Script.ps1: line 127 
at New-RunbookUnpublishedSnapshot, C:\Octopus\Work\20250522142431-284517-1362\Script.ps1: line 348 

After

Publishing a snapshot without a package
image

Publishing a snapshot with a package
image

Pre-requisites

  • Id should be a GUID that is not 00000000-0000-0000-0000-000000000000
    • NOTE If you are modifying an existing step template, please make sure that you do not modify the Id property (updating the Id will break the Library sync functionality in Octopus).
  • Version should be incremented, otherwise the integration with Octopus won't update the step template correctly
  • Parameter names should not start with $
  • Step template parameter names (the ones declared in the JSON, not the script body) should be prefixed with a namespace so that they are less likely to clash with other user-defined variables in Octopus (see this issue). For example, use an abbreviated name of the step template or the category of the step template).
  • LastModifiedBy field must be present, and (optionally) updated with the correct author
  • The best practices documented here have been applied
  • If a new Category has been created:
    • An image with the name {categoryname}.png must be present under the step-templates/logos folder
    • The switch in the humanize function in gulpfile.babel.js must have a case statement corresponding to it

Fixes #1607

…0 error while trying to create snapshot

Ensured Get-RunbookPackages always returns an array when publishing a snapshot.  Tested with an unpublished runbook with and without a package
@github-actions
Copy link

Start Hyponome locally

docker pull ghcr.io/hnrkndrssn/hyponome:main
docker run --rm -p 8000:8080 -it ghcr.io/hnrkndrssn/hyponome:main

Review in Hyponome

Copy link
Contributor

@hnrkndrssn hnrkndrssn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@hnrkndrssn hnrkndrssn merged commit 61b0feb into OctopusDeploy:master May 22, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run Octopus Deploy Runbook | fails with 500 error while trying to create snapshot

2 participants