Is it possible to clone or re-use one of the runbook CommunityActionTemplates objects? I am using the Octopus.Client.dll to try and accomplish this.
For example, I would like to re-use the ‘SQL - Execute Script’ community action template. I’m able to retrieve the template but I’m not sure how to add it as a step to an existing runbook? It’s possible to read the value from the action template and then apply it to each setting on a new action object, but I’m wondering if there is some way to easily clone the template as it does through the interface.
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURL, $OctopusAPIKey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
$Project = $repository.Projects.FindByName('My Test Project')
$ActionTemplate = $repository.ActionTemplates.FindByName('SQL - Execute Script')
$Runbook = $repository.Runbooks.CreateOrModify($Project,'My Runbook','Test Runbook Description')
$step = $Runbook.RunbookProcess.AddOrUpdateStep('StepOne')
$step.AddOrUpdateAction($ActionTemplate) | out-null
$Runbook.save()
I’ve tried a few ways to do this and I can’t get anything to work.
Thanks so much for your thoughts!