tag:help.appveyor.com,2012-11-13:/discussions/questions/35664-how-to-conditionally-skip-some-matrix-builds-for-the-prs-merge-into-branch-buildsAppVeyor: Discussion 2019-05-19T21:01:02Ztag:help.appveyor.com,2012-11-13:Comment/470844052019-03-18T14:05:32Z2019-03-18T14:05:32ZHow to conditionally skip some matrix builds for the PRs merge-into-branch builds?<div><p>I'm not sure how it may affect the rest of your config, but you could check <code>Do not build on "Pull request" events</code> in UI settings (this setting is only available from UI, and will be respected even if you use yaml file)?</p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/470844052019-03-18T14:16:05Z2019-03-18T14:16:05ZHow to conditionally skip some matrix builds for the PRs merge-into-branch builds?<div><p>I don't want to prevent the whole build - I just only want 2 of the 4 build types to run for these builds. The Dev/Stable and Stable/Dev variations in matrix are essentially "optional builds" that I only want to run for real pushes (as opposed to the synthentic merge builds created from a PR by GitHub).</p>
<p>Essentially, I want to add a condition similar to the <code>branches: only: - master</code> above that basically means "is not a PR".</p>
<p>Hope that makes sense!</p></div>dannytag:help.appveyor.com,2012-11-13:Comment/470844052019-03-18T17:52:06Z2019-03-18T17:52:06ZHow to conditionally skip some matrix builds for the PRs merge-into-branch builds?<div><p>There are a couple possible solutions with different pros/cons.</p>
<p>If you are looking to avoid extraneous use of concurrent jobs you could <a href="https://www.appveyor.com/docs/build-worker-api/#powershell-8">forcibly terminate</a> a build based on a script something like this at <code>init:</code> stage...<br></p>
<pre>
<code>ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -gt 0 -and ($env:ONLY_RUN_DART_VERSION -eq "DEV" -or $env:ONLY_RUN_CODE_VERSION -eq DEV) ) {Exit-AppveyorBuild}</code>
</pre>
Alternatively, if you are more interested in clean build history than not blocking jobs, you could create a separate project for those specific build matrix dimensions in which pull request events are disabled.</div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/470844052019-03-18T19:05:30Z2019-03-18T19:05:30ZHow to conditionally skip some matrix builds for the PRs merge-into-branch builds?<div><p>As long as it doesn't result in failed builds, that <code>init</code> option is probably fine. I'll give it a go tomorrow - thanks!</p></div>dannytag:help.appveyor.com,2012-11-13:Comment/470844052019-03-19T08:44:18Z2019-03-19T08:44:18ZHow to conditionally skip some matrix builds for the PRs merge-into-branch builds?<div><p>The init script appears to have worked great! The condition I wanted was:</p>
<pre>
<code>$env:APPVEYOR_PULL_REQUEST_NUMBER -gt 0 -and ($env:ONLY_RUN_DART_VERSION -ne $env:ONLY_RUN_CODE_VERSION)</code>
</pre>
<p>Since I wanted Dev/Dev and Stable/Stable to run. The builds are quit early and marked green :-)</p>
<p>It'd be nice if there was a way to include this in the <code>for</code> block, in the same way you can control branches, do a "is not PR" filter if you're looking for work to do, but this fix is fine for what I wanted (which is really just to speed up my builds - they're quite slow and often end up in a big queue when I'm pushing things to several branches).</p>
<p>Thanks!</p></div>dannytag:help.appveyor.com,2012-11-13:Comment/470844052019-03-19T18:21:54Z2019-03-19T18:21:54ZHow to conditionally skip some matrix builds for the PRs merge-into-branch builds?<div><p>Thanks for the update. Feel free to make a <a href="https://github.com/appveyor/ci/issues/new?template=feature_request.md">feature request</a> if you think it's a common enough use case.</p></div>Owen McDonnell