Last active
December 12, 2017 00:40
-
-
Save markryd/b3234ef3074c828fa8e9fdc22b804384 to your computer and use it in GitHub Desktop.
Update DeploymentStepPackageRequirement in all projects
This file contains 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
# This script requires DeploymentStepPackageRequirement which is scheduled for release in Octopus 4.2 | |
# You can this dll from your Octopus Server/Tentacle installation directory or from | |
# https://www.nuget.org/packages/Octopus.Client/ | |
Add-Type -Path 'C:\path\to\client\lib\Octopus.Client.dll' | |
$apikey = 'API-YOURAPIKEY' # Get this from your profile | |
$octopusURI = 'http://localhost:8065' # Your server address | |
# create the connection to the Octopus Server | |
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey | |
$repository = New-Object Octopus.Client.OctopusRepository $endpoint | |
# fetch all projects | |
$projects = $repository.Projects.GetAll() | |
foreach ($project in $projects) { | |
# iterate through the projects and fetch the deployment process | |
$process = $repository.DeploymentProcesses.Get($project.DeploymentProcessId) | |
# iterate through each "parent" step in the deployment process | |
foreach($step in $process.Steps) { | |
# check if this is one we want to update | |
# we may need more complciated logic here to determine which deployment steps need updating. | |
# perhaps every step before some other step or something similar? | |
if ($step.Name -like "*_build_*") { | |
$step.WithPackageRequirement([Octopus.Client.Model.DeploymentStepPackageRequirement]::BeforePackageAcquisition) | |
$repository.DeploymentProcesses.Modify($process) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment