Clone Variable Set


Is there a way cloning variable set and assign it to a project using API?


Thanks for getting in touch! This can be done via the API, however we have nothing currently written for this using the Octopus.Client, or REST. (See scripts:
If you wish to directly use Octopus.Client or REST, you will be able to write something with the linked scripts for reference.

The other option is to use Octoposh and the following commands:

#Get variable set from Source project
$SourceProjectVariableSet = Get-OctopusVariableSet -ProjectName Project1

#Get variable set from destination project
$DestinationProjectVariableSet = Get-OctopusVariableSet -ProjectName Project2

#Set [Destination] variables equal to [Source] Variables
$DestinationProjectVariableSet.Resource.Variables = $SourceProjectVariableSet.Resource.Variables

#Update the variable set in Octopus
Update-OctopusResource -Resource $DestinationProjectVariableSet.Resource

OctoPosh is a PowerShell module that uses a combination of calls to the Octopus REST API and Octopus.Client. The following page has some information on installing the OctoPosh module and what is available.

Let me know how you go.

Best regards,