Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Last active April 11, 2016 15:39
Show Gist options
  • Save Dalmirog-zz/0fa1116a496b8b545a7d to your computer and use it in GitHub Desktop.
Save Dalmirog-zz/0fa1116a496b8b545a7d to your computer and use it in GitHub Desktop.
Create release passing package version
$apiKey = "" #Octopus API Key
$OctopusURL = "" #Octopus URL
$ProjectName = "" #project name
$Header = @{ "X-Octopus-ApiKey" = $apiKey }
#Getting Project By Name
$Project = Invoke-WebRequest -Uri "$OctopusURL/api/projects/$ProjectName" -Headers $Header| ConvertFrom-Json
#Getting Deployment Template to get next release version
$dt = Invoke-WebRequest -Uri "$OctopusURL/api/deploymentprocesses/deploymentprocess-$($Project.id)/template" -Headers $Header | ConvertFrom-Json
#Creating Release
#add an extra node to SelectedPackages for each package you want to deploy, on this example i'm deploying 2
#To select the next release version, i'm using the [NextVersionIncrement] method of the deployment template. You could also put a literal version string here.
$Body = @"
{
"ProjectId":"$($Project.Id)",
"Version":"$($dt.nextversionincrement)",
"SelectedPackages":[{"StepName":"Deploy1","Version":"1.0.3"},
{"StepName":"Deploy2","Version":"1.0.0.7"}]
}
"@
Invoke-WebRequest -Uri $OctopusURL/api/releases -Method Post -Headers $Header -Body $Body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment