Hi OctopusSchaff,
I’m just jumping in for Finnian as he’s finished for today. I am not quite sure I understand what your after, but I will try to clarify a little bit and provide hopefully a good starting point.
“Release” is generally a term associated with the project, not Runbooks. Any modification, (including creating snapshots or running Published or Draft runbooks) will not have any effects on the Project where the Runbook is accessed from.
There are a number of variables that are unique to a runbook. I’ve Bolded the variable below and provided an example output.
Runbook ID Runbooks-362
Runbook Name Runbook Details
Octopus.Runbook.Id Runbooks-362
Octopus.RunbookRun.Id RunbookRuns-1079
Octopus.RunbookRun.Name Run on Development example for Tenants
Octopus.RunbookSnapshot.Id RunbookSnapshots-714
Octopus.RunbookSnapshot.Name Snapshot Q26BDDP
Octopus.RunbookSnapshot.Notes Manually entered Notes
Octopus.Web.RunbookSnapshotLink /app#/Spaces-162/snapshots/RunbookSnapshots-714
Octopus.Web.RunbookRunLink /app#/Spaces-162/runs/RunbookRuns-1079
Here’s an example of how you would access it in a runbook. $OctopusParameters[“Octopus.Runbook.Id”]
You can also use API calls to interrogate your runbooks.
Here is an example script, that will take a Tenant Name, Environment Name and Project Name and return any runbook runs that meet that specific criteria.
$ErrorActionPreference = "Stop";
# Define working variables
$octopusURL = "https://yourinstance.octopus.app"
$octopusAPIKey = "API-XXXXXXXXXXXXXXXXX"
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$spaceName = "Default"
$projectName = "Project Name with Runbooks"
$tenantName = "Client A"
$environmentName = "Development"
# Get Space from Space Name
$space = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/spaces/all" -Headers $header) | Where-Object {$_.Name -eq $spaceName}
# Get the ID of the Project, Tenant and Environment based on the name.
$project = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/$($space.Id)/projects/all" -Headers $header) | Where-Object {$_.Name -eq $projectName}
$environment = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/$($space.Id)/Environments/all" -Headers $header) | Where-Object {$_.Name -eq $environmentName}
$tenant = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/$($space.Id)/tenants/all" -Headers $header) | Where-Object {$_.Name -eq $tenantName}
# Get Entire List of Runbookruns from Space.Id
$runbookruns = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/$($space.Id)/runbookRuns" -Headers $header)
# Return Results based on Tenant, Project and Environment
$results = $runbookruns.Items | Where-Object {($_.TenantId -eq $tenant.Id) -and ($_.ProjectId -eq $project.Id) -and ($_.EnvironmentId -eq $environmentId)}
$results
I am hoping that this will be enough information for you to put together what you need to, in order to get exactly the information you are after. If I have missed the end goal of what you were trying to achieve, Myself or Finnian (or any other member of the support team) will be more than happy to keep helping you out.
Please, just reach out, and try to clarify exactly the output you are after. Perhaps an Mock example of what you wish the output to look like.
Regards,
Dane