tag:help.appveyor.com,2012-11-13:/discussions/questions/2821-triggering-deployment-project-from-environmentsAppVeyor: Discussion 2018-08-25T02:10:04Ztag:help.appveyor.com,2012-11-13:Comment/413652752016-12-01T00:39:27Z2016-12-01T00:39:27ZTriggering Deployment Project From Environments<div><p>Hi Eric,</p>
<p>What about different option -- create multiple deployment
environments, and call them with API, and use API to ensure that
they completed OK.</p>
<p>Please look at <a href="https://gist.github.com/IlyaFinkelshteyn/d0e6f92a73824ecb1f7fd0a053bd1407">
this sample</a>.</p>
<p>Let us know if this can work fro you.</p>
<p>--ilya.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/413652752016-12-01T01:16:45Z2016-12-01T01:16:46ZTriggering Deployment Project From Environments<div><p>I'm not sure that this script does what I am asking. Let me
explain it better. If I have two projects (we'll call them project
A and project B), I want them deployed to the same azure cloud
service. I would use a deployment project to pull in the artifacts
from these projects and deploy them together. What I want to do is
to be able to then promote the build for one of the projects (lets
say project A) to a staging environment. The staging deployment
needs to deploy both project a and project b but should know to
only pull the update for project A and to use an existing artifact
for project B.</p></div>Eric Mooneytag:help.appveyor.com,2012-11-13:Comment/413652752016-12-01T20:13:07Z2016-12-01T20:13:07ZTriggering Deployment Project From Environments<div><p>Eric, if you publish those packages to your personal feed (in
AppVeyor), then you could certainly create another project that has
your Azure server as the deploy target and run a script to grab
those previously built packages and push them. If you are using
something like a .nuspec file you could easily leave the
dependencies open so that it will pull the latest of A or B, and
you could also use the "cache folder" option in AppVeyor so it
shouldn't have to redownload the second package.</p>
<p>There might be a slightly cleaner way to do it, but that should
work.</p></div>dragon788tag:help.appveyor.com,2012-11-13:Comment/413652752016-12-06T08:18:46Z2016-12-06T08:18:46ZTriggering Deployment Project From Environments<div><p><strong>@dragon788</strong> thank you! However I think that Eric
needs something different.</p>
<p><strong>Eric</strong>, do I understand you correctly if I
describe your requirements this way:</p>
<ul>
<li>
<p>Single deployment project which by default deploys artifacts
from the latest build from ProjectA and ProjectB</p>
</li>
<li>
<p>Ability to call deployment project with parameter, which can be
used to dictate what build version to use when downloading
artifacts specific project.</p>
</li>
</ul>
<p>If my understanding is correct, this should be doable:</p>
<ul>
<li>
<p>Please note that among other variable you have to set the
following:</p>
<p><strong>deploy_version - build version to deploy. If not
specified artifacts from the most recent version will be
downloaded.</strong></p>
<p>You probably will have to setup it twice, for both ProjectA and
ProjectB, like <code>deploy_version_a</code> and
<code>deploy_version_b</code>. Then each of them will be passed to
<code>deploy.ps1</code> which will download artifacts. By default
it is empty which will make it use latest build.</p>
</li>
<li>
<p>So for staging deployment you can alter this variable to use
older build version for ProjectB. To start deployment build and
pass specific environment variable you can use <a href="https://www.appveyor.com/docs/api/projects-builds/#start-build-of-branch-most-recent-commit">
API</a>. So you just pass specific value of
<code>deploy_version_b</code> when starting deployment project
build.</p>
</li>
</ul>
<p>Here is sample of PS script to start this deployment:<br></p>
<pre>
<code>$deploy_version_b = <set_your_previous_version_for_projectB_build>
$token = '<your_api_token>'
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$body = @{
accountName="<your_account_name>"
projectSlug="<your_deployment_project_name>"
branch="master"<br> environmentVariables = @{
deploy_version_b=$deploy_version_b
}<br>}
$body = $body | ConvertTo-Json
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/builds' -Headers $headers -Body $body -Method POST</code>
</pre>
<p>Hope this helps.<br>
Ilya.</p></div>Ilya Finkelshteyn