tag:help.appveyor.com,2012-11-13:/discussions/questions/5082-preventing-master-ci-run-when-a-commit-a-made-on-a-feature-branchAppVeyor: Discussion 2018-08-25T02:18:21Ztag:help.appveyor.com,2012-11-13:Comment/428729002017-06-29T19:59:08Z2017-06-29T20:00:31ZPreventing master CI run when a commit a made on a feature branch<div><p>Currently, when I push a commit to a feature branch (linked to a Github PR), appveyor triggers two builds – one for the commit on the PR, and another one for the commit against master. How do I prevent the latter?</p>
<p>My <code>appveyor.yml</code> doesn't specificy this, since I want the feature branches to build.</p>
<pre>
<code>branches:
only:
- master</code>
</pre>
<p>Thanks</p></div>akshaytag:help.appveyor.com,2012-11-13:Comment/428729002017-06-29T20:41:11Z2017-06-29T20:41:11ZPreventing master CI run when a commit a made on a feature branch<div><p>Could you please elaborate scenario a little bit? My understanding is the following:</p>
<ul>
<li>You created initial PR
<ul>
<li>Both feature and master branch builds triggered and this is OK</li>
</ul>
</li>
<li>You created another commit to the same feature branch
<ul>
<li>Both feature and master branch builds triggered but this time you what it happen only in feature branch</li>
</ul>
</li>
</ul>
<p>Is my understanding correct?</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/428729002017-06-29T20:53:30Z2017-06-29T21:12:28ZPreventing master CI run when a commit a made on a feature branch<div><p>So say I have a branch <code>X</code>. I push a commit to that branch <code>X</code>. I want only that branch <code>X</code> to build, not <code>master</code>. In case a PR has been created for that branch I want it to behave in the same way (i.e. only branch <code>X</code> should build).</p>
<p>When this PR gets merged into <code>master</code>, only then <code>master</code> should build.</p>
<p>How do I do this?</p></div>akshaytag:help.appveyor.com,2012-11-13:Comment/428729002017-06-30T18:54:58Z2017-06-30T18:54:58ZPreventing master CI run when a commit a made on a feature branch<div><p>OK, now I understand. We have opposite feature, option to set <strong>Do not build feature branches with open Pull Requests</strong>. We might think of implementing something like *<em>Do not build virtual merge on *</em>, can you please provide some business justification, in what scenario you do not need virtual merge?</p>
<p>As workaround we can propose to edit YAML <strong>only in feature branch</strong> to have<br></p>
<pre>
<code>branches:
only:
- <feature_branch></code>
</pre>
and then revert this change before merge. Changes in YAML themselves can be done with <code>[skip ci]</code> or <code>[ci skip]</code> anywhere to commit message, to avoid triggering unneeded builds. I admin that this is not most elegant solution though...
<p>Ilya.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/428729002017-06-30T19:13:27Z2017-06-30T19:13:27ZPreventing master CI run when a commit a made on a feature branch<div><p>Our test phase is a heavy weight and un-conventional. It tests the building<br>
of images etc. We use the GH PR feature which checks that the PR must<br>
update with the master before the merge can happen. This ensures the PR is<br>
update with master before a merge, and that a corresponding CI run against<br>
the latest master has happened. So, we would like the flexibility to not<br>
run the virtual merges on every commit on a feature branch, and instead<br>
rely on the CI run triggered by the commit of master merging into the<br>
feature branch.</p></div>akshaytag:help.appveyor.com,2012-11-13:Comment/428729002017-07-01T00:54:57Z2017-07-01T00:54:57ZPreventing master CI run when a commit a made on a feature branch<div><p>Do you need this for clean build history, or to free up number of parallel jobs? If later, you can also call one of <a href="https://www.appveyor.com/docs/build-worker-api/#forcibly-terminate-current-build-with-success">exit commands</a> at <code>init</code> stage if <code>APPVEYOR_REPO_BRANCH</code> is <code>master</code> and <code>APPVEYOR_PULL_REQUEST_NUMBER</code> is not <code>NULL</code> (or <code>DEFINED</code> if you use <code>CMD</code>). Job will be stopped immediately, though some time will be still lost on job/VM creation.<br>
In any case I created <a href="https://github.com/appveyor/ci/issues/1636">GH issue</a> to track this feature request.</p></div>Ilya Finkelshteyn