tag:help.appveyor.com,2012-11-13:/discussions/suggestions/734-option-empty-default-branch-to-be-the-most-recent-commit-from-the-branches-to-build-settingsAppVeyor: Discussion 2018-10-19T08:17:18Ztag:help.appveyor.com,2012-11-13:Comment/373406842015-07-09T06:53:25Z2015-07-09T06:53:41ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Hi,</p>
<p>see this pic:</p>
<p><img alt="" src="http://i.imgur.com/IoGY07B.png"></p>
<p>I look at these two settings as:</p>
<p><strong>Default Branch</strong> : when ever i <em>manually</em>
push the BUILD button in AV, it will git clone etc from that
branch.<br>
<strong>Branches to build</strong> : when a git webhook is sent to
AV, AV will <em>decide</em> if it should git clone, based on the
settings, here.</p>
<p>Would be awesome if <strong>Default Branch</strong> could have
the option to get the latest commit from whatever setting is in
<strong>Branches to build</strong>.</p>
<p>For example. I have:</p>
<pre>
<code>branches:
exclude:
- master</code>
</pre>
<p>so when i <em>manually</em> press the build button in AV, it
will grab the most recent commit that is NOT from the
<code>master</code> branch. Boom! awesome!</p>
<p>Otherwise, set a value and it's the most recent commit from that
branch (as is what's happening, now).</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-09T09:02:12Z2015-07-09T09:02:12ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Also - are the <strong>Default Branch</strong> &
<strong>Branches to Build</strong> in the GUI totally separate and
independant to the <code>branches:</code> section in the
<code>yml</code>? (my question above is suggesting they are
linked...)</p>
<p>ie.**Default Branch** & <strong>Branches to Build</strong>
are used to determine if the build <em>should start/kick off</em>
while the <code>branches:</code> section i the <code>.yml</code>
file is used to split out config data _AFTER the build has been
determined to go ahead and start?</p>
<p>eg.</p>
<ul>
<li>if <code>master</code> kick off build (GUI Setting)</li>
<li>Ok .. we have a build started .. now ... if master, then deploy
here, else deploy there... (config file setting)</li>
</ul></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T01:51:25Z2015-07-10T01:51:25ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>"Default Branch" and "Branches to Build" are separate from those
one in appveyor.yml. Basically, it's either UI or YAML there.</p>
<p>Regarding getting commit of "not master" - nice idea but I'm not
sure if it's possible using GitHub API.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T02:01:19Z2015-07-10T02:01:19ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><blockquote>
<p>"Default Branch" and "Branches to Build" are separate from those
one in appveyor.yml. Basically, it's either UI or YAML there.</p>
</blockquote>
<p>So .. if it's UI or YAML .. if i go the YAML way, how does the
AV service know when to pull down .. if using the file means it has
to pull down first to find the file to check what branches to
use?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T02:11:43Z2015-07-10T02:11:43ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>It just fetches a single <code>appveyor.yml</code> at specified
commit ID using GitHub API.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T02:24:25Z2015-07-10T02:24:25ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>AH! winnah!!</p>
<p>so does that mean .. basically ... the only UI elements in the
project settings are</p>
<ul>
<li>Project name</li>
<li>Next build number</li>
<li>git repo details</li>
</ul>
<p>the only settings that are NOT available via a YAML file?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T02:29:03Z2015-07-10T02:29:03ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Also - another question about this..</p>
<p>if the AV service uses either the UI or the File ... what would
the UI look like if i did this file setting in the UI</p>
<pre>
<code>branches:
except:
- master</code>
</pre>
<p>Basically, the UI has 2 settings .. and the file has 1?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T02:32:11Z2015-07-10T02:32:11ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Like that?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T02:44:09Z2015-07-10T02:44:09ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>How do you define the <code>default branch</code> in file?</p>
<p>also, the previous q (above) about UI elements?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T02:49:08Z2015-07-10T02:49:08ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Ah, Default branch is on UI only. Sorry if I confused you.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T03:53:57Z2015-07-10T03:53:57ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Sweet. ok. i've fired off a support query to GH to see if they
have some GH Api :sparkle: magic that can do this :)</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-10T06:28:25Z2015-07-10T06:28:25ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>OK . GH replied. First, their reply, them my comment...</p>
<blockquote>
<p>Hi Pure Krome,</p>
<p>The only API endpoint which will give you timestamps for when a
commit was pushed is the Events API:</p>
<p><a href="https://developer.github.com/v3/activity/events/">https://developer.github.com/v3/activity/events/</a></p>
<p>The Events API allows you to fetch the last 300 events for a
repository, so you could check that and see if you notice a
PushEvent:</p>
<p><a href="https://developer.github.com/v3/activity/events/types/#pushevent">https://developer.github.com/v3/activity/events/types/#pushevent</a></p>
<p>The latest PushEven will contain the most recent commit. If you
don't notice any PushEvents, then you can't determine which commits
were pushed most recently -- you can only determine which commits
are at the tips of the repository's branches:</p>
<p><a href="https://developer.github.com/v3/repos/#list-branches">https://developer.github.com/v3/repos/#list-branches</a></p>
<p>Another approach would be to set up a webhook on the repository
so that you get notified of all push events:</p>
<p><a href="https://developer.github.com/webhooks/">https://developer.github.com/webhooks/</a></p>
<p>I hope this answers your question.</p>
</blockquote>
<p>Right now, my repo's look like they have WebHooks wired up
already, so you could leverage the <code>Push Event</code> that
occurs with the webhook and just read what branch the commit
occurred against:</p>
<p><a href="https://developer.github.com/v3/activity/events/types/#pushevent">https://developer.github.com/v3/activity/events/types/#pushevent</a></p>
<p>and then use the <code>ref</code> payload value :)</p>
<p>WIN!</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-14T01:07:26Z2015-07-14T01:08:15ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Also - if it's possible to do this ... then this could also be
added to a YAML file?</p>
<pre>
<code>branches
except:
- master
defaultbranch: any</code>
</pre>
<p>^ where any is a reserverd word (documented) or that value can
be left empty... (as the title of this post, suggested)</p>
<pre>
<code>branches
except:
- master
defaultbranch:</code>
</pre></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-14T01:10:35Z2015-07-14T01:10:35ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Push event is wired anyway. As far as I understand their
suggestion is to collect information about pushes and then use last
push. It won't work if webhook disabled. I'd leave default branch
on UI.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/373406842015-07-14T01:15:29Z2015-07-14T01:15:29ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>But ... nothing would work if the webhook is disabled? that's
how AV works, right?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-14T01:21:22Z2015-07-14T01:21:22ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>You can start new builds with "New build" button - many users do
manual or scheduled builds.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/373406842015-07-14T01:35:28Z2015-07-14T01:35:28ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>but doesn't that button just read the value of the <code>Default
branch</code> .. which might defeat the purpose of what I'm trying
=> eg. run a new build of the most recent commit. (well, that's
usually what i want to try and do).</p>
<p>side note: i do understand the process when people want to push
a button, to manually kick of a live/production
build/deployment.</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/373406842015-07-14T01:50:44Z2015-07-14T01:50:44ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>Yes, it reads default branch and gets the latest commit from
that branch. Looks like what you are trying to do can be
accomplished by going to a history and clicking "Re-build commit"
on the top most one.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/373406842015-07-14T04:42:20Z2015-07-14T04:42:20ZOption: Empty Default branch to be the most recent commit from the Branches to build, settings.<div><p>NP. i'll close this off then. Cheers for walking through the
discussion with me.</p></div>Pure Krome