Created
January 25, 2015 04:41
-
-
Save Dalmirog-zz/ded59a51ad52b104be9b to your computer and use it in GitHub Desktop.
Clone Octopus Project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -Path "C:\Tools\Newtonsoft.Json.dll" | |
Add-Type -Path "C:\Tools\Octopus.Client.dll" #Make sure its version 2.6.x or higher. Otherwhise you'll get errors with the LifecycleId property | |
Add-Type -Path "C:\Tools\Octopus.Platform.dll" | |
$OctopusURI = "" #i.e "Http://Octopus.MyAwesomeCompany.com" | |
$apikey = "" #i.e "API-7CH6XN0HHOU7DDEEUGKUFUR1K" | |
$endpoint = new-object -TypeName Octopus.Client.OctopusClient(New-Object Octopus.Client.OctopusServerEndpoint($OctopusURI,$apikey)) | |
$repository = new-object Octopus.Client.OctopusRepository $endpoint | |
$newproject = New-Object Octopus.Client.Model.ProjectResource | |
$OriginalProject = $repository.Projects.FindByName("MyOriginalProject"); | |
$properties = [ordered]@{ | |
Name = "MyClonedProject" | |
Description = "Project cloned from $($OriginalProject.name)" | |
ProjectGroupId = $OriginalProject.ProjectGroupId | |
LifecycleId = $OriginalProject.LifecycleId | |
} | |
$newproject = New-Object Octopus.Client.Model.ProjectResource -Property $properties | |
$endpoint.post("~/api/projects?clone=" + $OriginalProject.Id, $newproject) |
According to octopus : "Octopus.Platform.dll was removed as part of 3.0 and all that functionality has been moved into its own package."
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI
If you run the above script and get the following error:
Cannot find an overload for "post" and the argument count: "2".
, you can add$null
to the call to.post
(e.g.$endpoint.post("~/api/projects?clone=" + $OriginalProject.Id, $newproject, $null)
)