Is it possible to retry/redeploy a previously successful deployment through command line? I know a list of deployments can be fetched from command line using aws deploy list-deployments
but I didn't find any option to rerun the deployment using deployment-id returned from this command. There is an option to retry a previously run deployment from console though.
Re-deployment is simply based on creating new-deployment using a previous version of your application. Unfortunately, there is no special redeploy
command for that.
In the docs there is example how to redeploy sample project:
aws deploy create-deployment --application-name HelloWorld_App --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name HelloWorld_DepGroup --s3-location bucket=codedeploydemobucket,bundleType=zip,key=HelloWorld_App.zip
Here's a bash script that finds the last successful deployment and deploys that. With a few simple changes you could
wait deployment-successful
then a notification or another actionapplicationName="my-application-name"
deploymentGroupName="my-deployment-group"
lastSuccessfulDeployment=$(aws deploy list-deployments --application-name $applicationName --deployment-group-name $deploymentGroupName --include-only-statuses "Succeeded" --query 'deployments[0]' --output text)
s3Location=$(aws deploy get-deployment --deployment-id $lastSuccessfulDeployment --query 'deploymentInfo.revision.s3Location')
aws deploy create-deployment --application-name $applicationName --deployment-group-name $deploymentGroupName --s3-location $s3Location
Clubbing other answers, I was able to make it work as below:
REGION=us-east-1
applicationName="MyApp"
deploymentGroupName="MyDeploymentGroup"
lastSuccessfulDeployment=$(aws deploy list-deployments --application-name $applicationName --deployment-group-name $deploymentGroupName --include-only-statuses "Succeeded" --query 'deployments[0]' --output text --region $REGION)
echo "lastSuccessfulDeployment: $lastSuccessfulDeployment"
s3LocationBucket=$(aws deploy get-deployment --deployment-id $lastSuccessfulDeployment --query 'deploymentInfo.revision.s3Location.bucket' --region $REGION --output text)
echo "s3LocationBucket: $s3LocationBucket"
s3LocationKey=$(aws deploy get-deployment --deployment-id $lastSuccessfulDeployment --query 'deploymentInfo.revision.s3Location.key' --region $REGION --output text)
echo "s3LocationKey: $s3LocationKey"
deploymentId=$(aws deploy create-deployment --application-name $applicationName --deployment-group-name $deploymentGroupName --deployment-config-name CodeDeployDefault.AllAtOnce --s3-location bucket=$s3LocationBucket,bundleType=zip,key=$s3LocationKey --region $REGION --query 'deploymentId' --output text)
echo "deploymentId: $deploymentId"
aws deploy wait deployment-successful --deployment-id $deploymentId --region $REGION
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.