Clone Variable Set

viral.patel's Avatar

viral.patel

17 Jul, 2017 03:19 PM

Hi,

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

  1. Support Staff 1 Posted by Daniel Fischer on 18 Jul, 2017 05:04 AM

    Daniel Fischer's Avatar

    Hi,

    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: https://github.com/OctopusDeploy/OctopusDeploy-Api)
    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.
    http://octoposh.readthedocs.io/en/latest/gettingstarted/installing-...

    Let me know how you go.

    Best regards,
    Daniel

  2. Paul Stovell closed this discussion on 01 Nov, 2017 01:43 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac