tag:help.appveyor.com,2012-11-13:/discussions/questions/36780-different-images-per-branch-per-projectAppVeyor: Discussion 2019-06-25T21:01:17Ztag:help.appveyor.com,2012-11-13:Comment/471856172019-04-17T19:55:48Z2019-04-17T19:55:48ZDifferent images per branch / per project<div><p>For differentiation between branches you can <a href="https://www.appveyor.com/docs/build-configuration/#specializing-matrix-job-configuration">specialize build matrix configuration</a> using <code>for.matrix</code> construct.<br>
While for differentiation between operating system, you can use <code>$isLinux</code> variable and other strategies as outlined <a href="https://www.appveyor.com/docs/getting-started-with-appveyor-for-linux/#running-windows-and-linux-builds-side-by-side">here</a>.</p>
<p>Let me know if you have more questions or if I've misunderstood what kind of information you're looking for.</p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/471856172019-04-17T20:10:33Z2019-04-17T20:10:33ZDifferent images per branch / per project<div><p>We are using the hybrid model where we are using our own azure vhds, do<br>
you have an example like that? Different cloud images in a matrix?</p></div>Chris Belfieldtag:help.appveyor.com,2012-11-13:Comment/471856172019-04-17T21:17:53Z2019-04-17T21:17:53ZDifferent images per branch / per project<div><p>Use <a href="https://www.appveyor.com/docs/branches/#sharing-common-configuration-between-branches">branches-specific configuration</a> and use specific images for the different branches using <a href="https://www.appveyor.com/docs/build-environment/#using-multiple-images-for-the-same-build">image or environment sections</a>, by placing them under the <code>for.branches</code> construct.</p>
<pre>
<code>#default image matrix
image:
- Visual Studio 2017
- Ubuntu
############################
# default build scenario here #
############################
# run develop branch builds on Azure
for:
-
branches:
only:
- develop
image: AzureImage
# optionally develop-specific build scenario here</code>
</pre>
<p>For the build scenario, use <a href="https://www.appveyor.com/docs/getting-started-with-appveyor-for-linux/#running-windows-and-linux-builds-side-by-side">this part of documentation</a> to have a different scenarios for Linux and Windows. Note that both documentation and Owen (in previous answer) mention <a href="https://www.appveyor.com/docs/build-configuration/#specializing-matrix-job-configuration">build matrix specialization</a>. I would <strong>not</strong> recommend it for your case, as it does not work together with branches specialization you need to use. So use other options to distinguish between Windows and Linux build like <code>sh</code> and <code>cmd</code> prefixes or <code>$isLinux/$isWindows</code> variables.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/471856172019-04-22T16:54:10Z2019-04-22T16:54:14ZDifferent images per branch / per project<div><p>[image: Screen Shot 2019-04-22 at 5.52.12 pm.png] Should I not be seeing "test script hot" as it's a PR branch?<br>
[image: Screen Shot 2019-04-22 at 5.52.18 pm.png]</p></div>Chris Belfieldtag:help.appveyor.com,2012-11-13:Comment/471856172019-04-22T17:21:11Z2019-04-22T17:21:11ZDifferent images per branch / per project<div><p>For <strong>PR builds</strong> <code>branch</code> is the base/target one, e.g. <code>develop</code> in your case so it follows <code>develop</code> scenario. And this makes sense because <strong>PR build</strong> is a build of a "virtual merge" of from head branch to the base one. Kind of "what if I merge" build.</p>
<p>When you did initial commit, <strong>branch build</strong> probably happened, and that one should follow <code>for.branches.except: develop</code> scenario.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/471856172019-04-22T18:51:58Z2019-04-22T18:51:58ZDifferent images per branch / per project<div><p>Hmm, I didn't notice that in the history of the project? (where it build<br>
the branch by itself without the PR).</p>
<p>Is there a log I can check?</p></div>Chris Belfieldtag:help.appveyor.com,2012-11-13:Comment/471856172019-04-22T19:55:49Z2019-04-22T19:55:49ZDifferent images per branch / per project<div><p>If it does not, check if <code>Do not build on "Push" events</code> is checked in general tab of the project setting by any chance. If not, check project's <code>Events</code> tab -- we write a warning if we skip a build. And finally if nothing helps, check webhook settings for your project on GitHub and ensure if it sends requests on <code>push</code> events.</p>
<p>Let us know what you found.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/471856172019-04-23T12:45:11Z2019-04-23T12:45:12ZDifferent images per branch / per project<div><p>So we need the ability to only test develop independently on a "cold" image<br>
so that we can do a full test (which takes up to 5 hours) so we can't do<br>
that cold test on every commit (for obvious reasons). Could you give me an<br>
example where I can run a "cold image" on develop only (maybe on a<br>
schedule) and then use a "warm" image for the PRs.</p></div>Chris Belfieldtag:help.appveyor.com,2012-11-13:Comment/471856172019-04-23T20:50:51Z2019-04-23T20:50:51ZDifferent images per branch / per project<div><p>There are a lot of options to do that, but for me the most straightforward one would be creating of two AppVeyor projects this way:</p>
<ul>
<li>
<p>Both projects connected to the same repository.</p>
</li>
<li>
<p>At least one of the projects would have URL slug with random ending. You can change it to something nicer with API call, check <a href="https://gist.github.com/IlyaFinkelshteyn/8f195010434075074bfa4ee48e3fa347">sample script</a>.</p>
</li>
<li>
<p>Each project uses <a href="https://www.appveyor.com/docs/build-configuration/#yaml-file-alternative-naming">custom YAML</a>.</p>
</li>
<li>
<p>Scheduled build project has default branch set to <code>develop</code> in UI General Settings.</p>
</li>
<li>
<p>Scheduled build project has cron schedule set in UI General Settings. Use <a href="https://crontab.guru/">crontab guru</a> to test your expression.</p>
</li>
<li>
<p>Scheduled build project has <code>Do not build on "Push" events</code> and <code>Do not build on "Pull request" events</code> set in UI General Settings.</p>
</li>
<li>
<p>Scheduled build project has "cold" image test in YAML.</p>
</li>
<li>
<p>PR build project has <code>Do not build on "Push" events</code> set in UI General Settings.</p>
</li>
<li>
<p>Scheduled build project has "warm" image test in YAML.</p>
</li>
</ul>
<p>The only disadvantage of this is two build histories, but depending on the situation this even may be good. Also you can have two separate <a href="https://www.appveyor.com/docs/status-badges/">status badges</a> on your dashboard or GitHub.</p>
<p>If you do not like this approach and want to keep common project and YAML, you can condition your test script with <code>APPVEYOR_PULL_REQUEST_NUMBER</code> and/or <code>APPVEYOR_SCHEDULED_BUILD</code> <a href="https://www.appveyor.com/docs/environment-variables/">environment variables</a>. Ping with any questions if you decide to go this route.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/471856172019-04-24T08:25:02Z2019-04-24T08:25:03ZDifferent images per branch / per project<div><p>Could you provide a working example of something like this?</p></div>Chris Belfieldtag:help.appveyor.com,2012-11-13:Comment/471856172019-04-24T21:45:57Z2019-04-24T21:45:57ZDifferent images per branch / per project<div><p>I proposed two solutions above.</p>
<p>First solution is creating two separate projects. This approach wrote with as much details as I could.</p>
<p>Second solution is to keep a single project and YAML. If you want to stay with it, send your YAML as a text (not picture) and I will send you an example based on it.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/471856172019-04-25T07:31:45Z2019-04-25T07:31:46ZDifferent images per branch / per project<div><p>Here is our current single project appveyor config file :)</p>
<p>So basically we need something that does cold (image: hc-cold) builds only<br>
on develop, warm builds on prs (image: hc-azure) and if you could possibly<br>
give us something skeleton for azure / linux (call the image hc-linux) that<br>
we could use?</p>
<p>I will give the 2 project method a go today :)</p>
<p>Thanks!</p>
<p>Chris</p></div>Chris Belfieldtag:help.appveyor.com,2012-11-13:Comment/471856172019-04-25T07:59:43Z2019-04-25T07:59:45ZDifferent images per branch / per project<div><p>[image: Screen Shot 2019-04-25 at 8.58.50 am.png] Can this be enabled?</p></div>Chris Belfieldtag:help.appveyor.com,2012-11-13:Comment/471856172019-04-25T17:03:58Z2019-04-25T17:03:58ZDifferent images per branch / per project<div><p>Sure, enabled. Yes, I think that 2 projects approach is cleaner for your case.</p></div>Ilya Finkelshteyn