New machine in an environment deploy to itself?

logan.may's Avatar

logan.may

31 Aug, 2017 07:21 PM

I deploy to an autoscaling group on aws. If the group spins up a new instance and adds itself to the deployment environment, is there a way to run the most recent deployment on only itself without having to redeploy to the entire group? Thank you.

  1. 1 Posted by Ilya Finkelshte... on 31 Aug, 2017 11:03 PM

    Ilya Finkelshteyn's Avatar

    I believe that you are using AppVeyor deployment agent. In this case you can use deployment group to isolate deployment to single machine.

    Scenario is the following:

    • each machine on run script which:
      • installs AppVeyor deployment agent with the same deployment key, but unique deployment group
      • calls AppVeyor API to start deployment and passes specific group as a variable.
    • on AppVeyor side variable for the group has no value, so manual deployment will have no group and will be deployed to all machines.

    Here is sample script to run on AWS instances start:

    $token = "<TOKEN>"


    Invoke-WebRequest -Uri https://www.appveyor.com/downloads/deployment-agent/latest/AppveyorDeploymentAgent.msi -OutFile c:\admin\AppveyorDeploymentAgent.msi & msiexec /i c:\admin\AppveyorDeploymentAgent.msi /quiet /qn /norestart /log c:\admin\install.log ENVIRONMENT_ACCESS_KEY=$token DEPLOYMENT_GROUP=$env:computername


    $headers = @{ "Authorization" = "Bearer $token" "Content-type" = "application/json" }


    $body = @{ environmentName = "<YOUR_ENVIRONMENT>" accountName = "<YOUR_ACCOUNT>" projectSlug = "<YOUR_PROJECT_SLUG>" buildVersion = "<BUILD_VERSION>" environmentVariables = @{ "group" = $env:computername } } | ConvertTo-Json


    $Deployment = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/deployments" -Headers $headers -Method POST -Body $body

    Here is group-related environment settings screenshot:

  2. 2 Posted by logan.may on 31 Aug, 2017 11:38 PM

    logan.may's Avatar

    So for every package i have to create the provider setting of Artifact.group and set it to the environment variable. then if it's blank everyone gets it? but if it is set only that group gets it?

  3. 3 Posted by Ilya Finkelshte... on 31 Aug, 2017 11:55 PM

    Ilya Finkelshteyn's Avatar

    No, you don't have to. Just setup it with environment variable as on the screenshot, and then it will be substituted with unique AWS instance computer name on the fly.

  4. 4 Posted by logan.may on 31 Aug, 2017 11:57 PM

    logan.may's Avatar

    Perfect. One last thing to clarify. Do I need to add a provider setting of ArtifactName.group for each artifact I am deploying? (i have 5)

  5. 5 Posted by Ilya Finkelshte... on 01 Sep, 2017 12:09 AM

    Ilya Finkelshteyn's Avatar

    Yes, as long as you need the same selective behavior for all of them.

    P.S. That's OK if this is not last thing to clarify, this is tricky approach, please feel free to ask more :)

  6. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:19 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac