tag:help.appveyor.com,2012-11-13:/discussions/questions/15015-any-commonstandard-way-for-pulling-latest-versions-of-apps-to-newly-launched-instancesAppVeyor: Discussion 2018-10-19T08:18:36Ztag:help.appveyor.com,2012-11-13:Comment/442932032017-12-14T04:19:56Z2017-12-14T04:19:56ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>Hi Brian,</p>
<p>I believe the following scenario will work:</p>
<ol>
<li>
<p>For specific Environment, set deployment group name to be an environment variable as described <a href="https://www.appveyor.com/docs/deployment/agent/#overriding-settings-while-deploying-from-build">here</a>. Set existing value as default value so default behavior do not change.</p>
</li>
<li>
<p>On lunch of new instance set deployment group to <code>computername</code> environment variable. If you install AppVeyor deployment agent on startup, you probably already use <code>DEPLOYMENT_GROUP</code> command line parameter. If it is pre-installed, update it in registry key <code>HKEY_LOCAL_MACHINE\SOFTWARE\AppVeyor\DeploymentAgent</code> value name <code>DeploymentGroup</code>.</p>
</li>
<li>
<p>After that (also part as startup script) start Environment deployment with <a href="https://www.appveyor.com/docs/api/environments-deployments/#start-deployment">API</a>. Pass deployment group <code>computername</code> as environment variable (which you set in the step 1), so it will overwrite default deployment group and deployment will happen only to this instance.</p>
</li>
<li>
<p>In <a href="https://www.appveyor.com/docs/deployment/agent/#running-powershell-scripts-on-target-server-during-deployment">deploy.ps1 script</a>, which happens after deployment, reset deployment group name in registry to default value. If you have a risk that the same <code>deploy.ps1</code> will be called on instances in the different AWS scaling groups, send special environment variable (like <code>default_deploy_group</code>) when starting initial deployment on step 3 and make <code>deploy.ps1</code> use it when editing the registry.</p>
</li>
</ol>
<p>Hope this make sense. It can look complicated, so feel free to ask any additional questions. Also we are happy to help with script samples if needed.</p>
<p>Ilya.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/442932032018-01-08T21:56:52Z2018-01-08T21:56:52ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>Thanks - I have been playing with this and got it working, but now seem to be seeing some issues with the agent attempting to run two deploys simultaneously on the same group (machine, in this case). Is this intended behavior? It is causing sporadic failures as one deploy sets different environment variables than the other. E.g. an APPLICATION_PATH env var in one deploy is sometimes getting a value from another. Do I have to manage this in my script to ensure the deployments execute serially? Shouldn't the agent handle that?</p></div>brian.donahuetag:help.appveyor.com,2012-11-13:Comment/442932032018-01-08T21:58:07Z2018-01-08T21:58:07ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>To clarify, my instance serves multiple applications, and I am triggering the latest deployment for each project in my script. I figured they'd be queued serially, but they seem to run in parallel and that causes issues.</p></div>brian.donahuetag:help.appveyor.com,2012-11-13:Comment/442932032018-01-09T07:20:41Z2018-01-09T07:20:41ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>I see. Created <a href="https://github.com/appveyor/ci/issues/2016">this</a> issue. We believe we can implement it by the end of this week. Would you mind to test pre-release agent version as it available?</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/442932032018-01-09T18:51:55Z2018-01-09T18:51:55ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>That's awesome - I'm happy to help test!</p></div>brian.donahuetag:help.appveyor.com,2012-11-13:Comment/442932032018-01-27T04:37:01Z2018-01-27T04:37:01ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>Hi Brian,</p>
<p>Sorry it took longer than expected (<a href="https://www.appveyor.com/updates/2018/01/23/">recent update</a> took a lot of time). Can you please try <a href="http://www.appveyor.com/downloads/deployment-agent/5.2.2/AppveyorDeploymentAgent.msi">www.appveyor.com/downloads/deployment-agent/5.2.2/AppveyorDeploymen...</a> and see if problem disappears. No PowerShell colors with this implementation though, but I don't think you care too much :)</p>
<p>Ilya.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/442932032018-01-29T15:59:52Z2018-01-29T15:59:52ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>Hi Ilya,</p>
<p>I tested this several times, and have not reproduced the issue. I am also going to test it on spinning up new instances in an ASG, which is where I first saw it. In the meantime, I am having another issue with this approach that I don't understand. I added <code>${deployGroup}</code> as an environment setting for this project, and it works in my PS script when I set it to machine name, and also works when pushing to github, and setting it in <code>appveyor.yml</code> but triggering a deployment from the Appveyor console does not triggering any agents. I can't tell what <code>${deployGroup}</code> is being set to in that case, but I thought it would pick up the variable in the appveyor.yml, though it seems it doesn't... how can we get it to work from the Appveyor console/UI so that we can do things like roll back to previous versions? Can we only do this with the API now if we use <code>${...}</code> variables like this?</p></div>brian.donahuetag:help.appveyor.com,2012-11-13:Comment/442932032018-01-29T16:30:01Z2018-01-29T16:33:53ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>Hi Ilya,</p>
<p>Actually, I realized that I can set a default value in the Env Vars settings on the Environment. But that comes with another potential issue... I had been using a single <code>${deployGroup}</code> var name for all my apps, but having one default for that variable will cause issues (all apps deployed to same group when deployed via console). I guess you need a different environment variable name per Deploy Group, like <code>app1DeployGroup</code> <code>app2DeployGroup</code>.</p>
<p>This means I need I need another variable in my script to know which env variable to set with the deploy group, which is kind of ugly, though not the end of the world. :( Not sure how that can be improved. One idea that crossed my mind was allowing some sort of default to be set in environment settings like :<br>
<code>app1.deploy_group: ${deployGroup:app1group}</code> where <code>app1group</code> is the default if none is specified. Not sure that's very nice either. Let me know if you have thoughts....</p></div>brian.donahuetag:help.appveyor.com,2012-11-13:Comment/442932032018-01-29T17:00:48Z2018-01-29T17:00:48ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>Alas, I think the ultimate solution would be to enable triggering the appveyor agent locally (CLI or API) to pull a specific deployment to the target machine, similar to how CodeDeploy agent works in AWS. I would love to stick with Appveyor deployment, as I love the IIS integration, etc, but CodeDeploy has the edge here.</p></div>brian.donahuetag:help.appveyor.com,2012-11-13:Comment/442932032018-01-31T22:37:04Z2018-01-31T22:37:04ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>Hi Brian,</p>
<p>Sorry it took some time for me to digest the situation. Hope I understand it correctly. What about separate Environment (each with the same Environment access key) for each app? This will make PS script on local instance a little bit more complicated, but not to much.</p>
<p>Let us know what you think.</p>
<p>Ilya.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/442932032018-02-06T14:25:11Z2018-02-06T14:25:11ZAny common/standard way for pulling latest versions of apps to newly launched instances?<div><p>Been mulling this over. I think the multiple environment approach is our best bet. Took me a while to warm to the idea of having multiple environments for one conceptual environment like "production" but as we break our app into smaller and smaller sets of services I think it will actually make it easier for us to manage. Will give that a shot. Thanks for your help! I think I still might make a feature request for a CLI/API call that we can use to trigger deploying the latest version of all projects in an environment to that machine though :)</p></div>brian.donahue