Redeploy same versions to target - CLI

We are replacing our .Net webservers with a new OS and would like to use the CLI to get a list of the application versions deployed and then give the list back to the CLI to deploy to the newly built servers.

Server will have the same name ie the same target.

I see the CLI has an option to get a list of deployments in json format but i dont see how to deploy using that list

Hi @helen.paterson.abcam,

Thanks for getting in touch!

I’m wondering if Deployment Target Triggers would be of use here?
The trigger would deploy the last successful release to any deployment targets that fit the Event Filter.

The trigger can have the Redeploy setting enabled so that it re-deploys the latest version even if it thinks that the target already has it. As you’re overwriting current deployment targets this may be necessary.

Let me know if this would fit your requirements.

Regards,
Paul

******* Variables Section ******************

#Define these variables
$oct_server = “https://octopus.mydomain.com
$APIkey = “API-get fromgui”
$env = “DEV-CI”

*********************************************

#list projects with version
$json2 = d:\octo list-latestdeployments -server=https://octopus.abcam.com --environment=$env --apikey=$APIkey --outputformat=json | ConvertFrom-Json
$json2 | Select-Object -ExpandProperty Project -Property Version
#redeploy projects with version
#Deploy release - Octopus Deploy
$json2 | Select-Object -ExpandProperty Project | Select-Object Name,Version | Sort-Object -Property Name | foreach {
$app = $.Name
$ver = $
.Version
#test
#$json5 = “d:\octo deploy-release --project $app --releaseNumber $ver --deployto $env --server $oct_server --apiKey $APIkey --guidedFailure=True --debug”
#write-host $json5
#do
$json5 = d:\octo deploy-release --project $app --releaseNumber $ver --deployto $env --server $oct_server --apiKey $APIkey --guidedFailure=True --debug
}

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.