tag:help.appveyor.com,2012-11-13:/discussions/questions/8157-new-machine-in-an-environment-deploy-to-itselfAppVeyor: Discussion 2018-08-25T02:19:42Ztag:help.appveyor.com,2012-11-13:Comment/433344842017-08-31T23:03:42Z2017-08-31T23:03:42ZNew machine in an environment deploy to itself?<div><p>I believe that you are using AppVeyor deployment agent. In this case you can use <strong>deployment group</strong> to isolate deployment to single machine.</p>
<p>Scenario is the following:</p>
<ul>
<li>each machine on run script which:
<ul>
<li>installs AppVeyor deployment agent with the <strong>same deployment key</strong>, but <strong>unique deployment group</strong></li>
<li>calls AppVeyor API to start deployment and passes specific group as a variable.</li>
</ul>
</li>
<li>on AppVeyor side variable for the group has no value, so manual deployment will have no group and will be deployed to all machines.</li>
</ul>
<p>Here is sample script to run on AWS instances start:<br></p>
<pre>
<code>$token = "<TOKEN>"<br><br>
<br>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<br><br>
<br>$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}<br><br>
<br>$body = @{
environmentName = "<YOUR_ENVIRONMENT>"
accountName = "<YOUR_ACCOUNT>"
projectSlug = "<YOUR_PROJECT_SLUG>"
buildVersion = "<BUILD_VERSION>"
environmentVariables = @{
"group" = $env:computername
}
} | ConvertTo-Json<br><br>
<br>$Deployment = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/deployments" -Headers $headers -Method POST -Body $body</code>
</pre>
<p>Here is group-related environment settings screenshot:</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/433344842017-08-31T23:38:00Z2017-08-31T23:38:00ZNew machine in an environment deploy to itself?<div><p>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?</p></div>logan.maytag:help.appveyor.com,2012-11-13:Comment/433344842017-08-31T23:55:44Z2017-08-31T23:55:44ZNew machine in an environment deploy to itself?<div><p>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.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/433344842017-08-31T23:57:34Z2017-08-31T23:57:34ZNew machine in an environment deploy to itself?<div><p>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)</p></div>logan.maytag:help.appveyor.com,2012-11-13:Comment/433344842017-09-01T00:09:19Z2017-09-01T00:09:19ZNew machine in an environment deploy to itself?<div><p>Yes, as long as you need the same selective behavior for all of them.</p>
<p>P.S. That's OK if this is not last thing to clarify, this is tricky approach, please feel free to ask more :)</p></div>Ilya Finkelshteyn